:root {
    --bg: #08131f;
    --surface: rgba(255, 255, 255, 0.9);
    --text: #13253a;
    --text-muted: #4c6279;
    --border: rgba(20, 42, 68, 0.12);
    --accent: #ff6a45;
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 12px;
    --shadow: 0 24px 48px rgba(6, 22, 36, 0.15);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    font-family: "Manrope", sans-serif;
    color: var(--text);
    background: linear-gradient(160deg, var(--bg) 0%, #0e2740 42%, #17324a 100%);
    min-height: 100%;
}

h1,
h2,
h3 {
    margin: 0;
    font-family: "Fraunces", serif;
}

a {
    color: inherit;
    text-decoration: none;
}

p {
    margin: 0;
    line-height: 1.5;
}

.bg-orb {
    position: fixed;
    border-radius: 999px;
    filter: blur(3px);
    opacity: 0.32;
    pointer-events: none;
    z-index: 0;
}

.orb-one {
    width: 420px;
    height: 420px;
    background: radial-gradient(circle at 30% 30%, #ff8a5d, #ff5534);
    top: -120px;
    right: -80px;
}

.orb-two {
    width: 460px;
    height: 460px;
    background: radial-gradient(circle at 40% 30%, #32e0ad, #0ba778);
    left: -180px;
    bottom: -140px;
}

.bg-grid {
    position: fixed;
    inset: 0;
    background-image: linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-size: 34px 34px;
    mask-image: radial-gradient(circle at 50% 30%, rgba(0, 0, 0, 0.65), transparent 85%);
    pointer-events: none;
    z-index: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 60;
    backdrop-filter: blur(8px);
    background: rgba(7, 19, 31, 0.8);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.topbar-inner {
    max-width: 1260px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.brand-mark {
    height: 36px;
    width: auto;
    border-radius: 8px; /* Slightly softer for the new logo */
    background: transparent;
    display: inline-flex;
    place-items: center;
    color: white;
    font-weight: 800;
    overflow: hidden;
}
.brand-mark img,
.top-nav-icon-brand img,
.mobile-tab-icon-brand img {
    height: 100%;
    width: auto;
    max-width: none;
    object-fit: contain;
    display: block;
}

.brand-text {
    font-weight: 800;
    color: #ffffff;
    font-size: 1.1rem;
}

.top-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.top-nav > a,
.top-nav button {
    color: #e8f1ff;
    font-weight: 700;
    font-size: 0.95rem;
    padding: 8px 12px;
    border-radius: 999px;
}

.top-nav > a:hover,
.top-nav button:hover {
    background: rgba(255, 255, 255, 0.12);
}

.top-nav > a.pill-btn {
    color: #123d63;
    background: #f8fbff;
    border: 1px solid #c8dbef;
}

.top-nav-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.top-nav-icon {
    width: 24px;
    height: 24px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.24);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    line-height: 1;
}

.top-nav-icon-brand {
    border: none;
    background: transparent;
    color: #ffffff;
    font-weight: 800;
    overflow: hidden;
    padding: 0;
    width: auto !important; /* Override the default 30px width of .top-nav-icon */
}

.top-nav-avatar,
.top-nav-avatar-fallback {
    width: 26px;
    height: 26px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    object-fit: cover;
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    font-size: 0.78rem;
    font-weight: 800;
}

.top-nav-label {
    line-height: 1;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    font-size: 0.72rem;
    color: #fff;
    background: var(--accent);
    margin-left: 6px;
}

.inline-form {
    margin: 0;
}

.page-shell {
    position: relative;
    max-width: 1260px;
    margin: 18px auto 24px;
    padding: 0 18px;
}

.footer {
    text-align: center;
    color: rgba(236, 246, 255, 0.68);
    padding: 18px;
    font-size: 0.85rem;
    position: relative;
    z-index: 1;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.flash-stack {
    display: grid;
    gap: 10px;
    margin-bottom: 14px;
}

.flash {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.95rem;
}

.flash-success {
    color: #115741;
    background: #d7f7ec;
}

.flash-warning {
    color: #6f4a07;
    background: #ffeec9;
}

.flash-error {
    color: #6d1e1e;
    background: #ffd8d8;
}

.flash-info {
    color: #1c4d74;
    background: #ddefff;
}

.ghost-btn,
.pill-btn,
.primary-btn,
.secondary-btn,
.mini-btn,
.icon-btn {
    border: none;
    cursor: pointer;
    font-weight: 700;
    transition: transform 160ms ease;
}

.primary-btn {
    background: linear-gradient(130deg, var(--accent), #ff8f3f);
    color: #fff;
    padding: 11px 18px;
    border-radius: 999px;
}

.secondary-btn {
    background: linear-gradient(130deg, #1abf94, #0da579);
    color: #fff;
    padding: 11px 18px;
    border-radius: 999px;
}

.mini-btn {
    padding: 8px 12px;
    font-size: 0.82rem;
    border-radius: 999px;
    background: #edf3f9;
    color: var(--text);
}

.pill-btn {
    background: #edf3ff;
    color: #184777;
    padding: 8px 14px;
    border-radius: 999px;
}

.ghost-btn {
    background: rgba(255, 255, 255, 0.09);
    color: #e8f1ff;
    padding: 8px 12px;
    border-radius: 999px;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 999px;
    background: #edf3f9;
    color: #22476a;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.icon-btn svg {
    width: 18px;
    height: 18px;
}

.icon-btn.active {
    background: #ffe2d8;
    color: #b6432b;
}

.icon-send {
    background: linear-gradient(130deg, var(--accent), #ff8f3f);
    color: #fff;
}

.primary-btn:hover,
.secondary-btn:hover,
.mini-btn:hover,
.pill-btn:hover,
.ghost-btn:hover,
.icon-btn:hover {
    transform: translateY(-1px);
}

.stack-form {
    display: grid;
    gap: 10px;
}

label {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid #c7d5e5;
    border-radius: 12px;
    padding: 11px 12px;
    font: inherit;
    color: var(--text);
    background: #ffffff;
}

textarea {
    resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: #5f98cc;
    box-shadow: 0 0 0 4px rgba(95, 152, 204, 0.2);
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-size: 0.74rem;
    font-weight: 800;
    color: #70d9b8;
}

.muted {
    color: var(--text-muted);
    font-size: 0.82rem;
}

.hidden-form,
.hidden-input {
    display: none;
}

.auth-wrap {
    min-height: calc(100vh - 220px);
    display: grid;
    grid-template-columns: 1.1fr minmax(280px, 450px);
    gap: 24px;
    align-items: center;
}

.auth-hero {
    color: #ebf4ff;
    max-width: 560px;
    padding: 14px;
}

.auth-hero h1 {
    font-size: clamp(2rem, 4vw, 3.35rem);
    margin: 10px 0 12px;
}

.auth-hero p {
    color: rgba(235, 244, 255, 0.82);
    font-size: 1.06rem;
}

.auth-card {
    padding: 24px;
}

.auth-card h2 {
    margin-bottom: 16px;
}

.auth-inline-btn {
    margin-top: 12px;
    width: 100%;
    display: inline-flex;
    justify-content: center;
}

.switch-text {
    margin-top: 14px;
    color: var(--text-muted);
}

.switch-text a {
    color: #145a93;
    font-weight: 700;
}

.layout-grid {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr) 320px;
    gap: 18px;
    align-items: flex-start;
}

.left-rail,
.right-rail {
    padding: 18px;
    display: grid;
    gap: 18px;
}

.feed-column {
    display: grid;
    gap: 14px;
}

.profile-card {
    text-align: center;
    display: grid;
    gap: 8px;
}

.profile-icon-nav {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 4px;
}

.profile-icon-btn {
    width: 42px;
    height: 42px;
    border-radius: 999px;
    border: 1px solid #d4e3f2;
    background: linear-gradient(180deg, #fbfdff, #f1f7ff);
    color: #1e486b;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    font-size: 1.1rem;
    box-shadow: 0 8px 18px rgba(18, 48, 75, 0.08);
}

.profile-icon-btn:hover {
    background: linear-gradient(180deg, #f2f8ff, #e7f1ff);
}

.profile-icon-glyph {
    line-height: 1;
}

.profile-icon-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: #ff3b30;
    color: #ffffff;
    border: 2px solid #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 800;
}

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: linear-gradient(130deg, #0f4d84, #1776a9);
    color: #fff;
    font-weight: 800;
    flex-shrink: 0;
}

.avatar-circle {
    border-radius: 999px;
}

.avatar-big {
    width: 68px;
    height: 68px;
    margin: 0 auto;
    font-size: 1.35rem;
}

.avatar-small {
    width: 34px;
    height: 34px;
    font-size: 0.86rem;
}

.avatar-xsmall {
    width: 28px;
    height: 28px;
    font-size: 0.74rem;
}

.avatar.huge {
    width: 88px;
    height: 88px;
    font-size: 1.8rem;
}

.avatar-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.stats-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.stats-row > div {
    background: #f4f8fc;
    border: 1px solid #dde7f2;
    border-radius: 12px;
    padding: 10px;
    text-align: center;
}

.stats-row strong {
    display: block;
    font-size: 1rem;
}

.stats-row span {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.quick-actions {
    display: grid;
    gap: 10px;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.section-head a {
    font-size: 0.88rem;
    font-weight: 700;
    color: #1b6598;
}

.stories-bar-card {
    padding: 14px 16px;
}

.stories-scroll {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.story-slot {
    min-width: 84px;
    max-width: 84px;
    display: grid;
    gap: 6px;
    text-align: center;
}

.story-avatar-wrap {
    position: relative;
    width: 74px;
    height: 74px;
    margin: 0 auto;
}

.story-avatar-btn,
.story-avatar-link {
    border: none;
    background: transparent;
    padding: 0;
    cursor: pointer;
    display: block;
}

.story-ring {
    width: 74px;
    height: 74px;
    border-radius: 999px;
    padding: 3px;
    background: #d9e6f2;
    display: grid;
    place-items: center;
}

.story-ring.has-story {
    background: conic-gradient(from 130deg, #ff6a45, #ffb347, #ff6a45);
}

.story-ring.is-seen {
    background: #d9e6f2;
}

.story-avatar-image,
.story-avatar-fallback {
    width: 100%;
    height: 100%;
    border-radius: 999px;
    border: 2px solid #ffffff;
    object-fit: cover;
    background: #f4f8fd;
    display: grid;
    place-items: center;
    color: #194f7b;
    font-weight: 800;
}

.story-plus-badge {
    position: absolute;
    right: -2px;
    bottom: -2px;
    width: 24px;
    height: 24px;
    border-radius: 999px;
    background: linear-gradient(130deg, #1abf94, #0da579);
    color: #fff;
    border: 2px solid #ffffff;
    display: grid;
    place-items: center;
    font-weight: 800;
    line-height: 1;
    padding: 0;
}

.story-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: #eaf6ff;
    text-shadow: 0 1px 4px rgba(2, 9, 18, 0.55);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.publish-launch-card {
    padding: 12px;
}

.publish-launch-btn {
    display: inline-flex;
    width: 100%;
    justify-content: center;
    align-items: center;
    padding: 14px 16px;
    border-radius: 14px;
    font-weight: 800;
    color: #ffffff;
    background: linear-gradient(120deg, #ff6a45, #ff9b47);
}

.posts-stack {
    display: grid;
    gap: 12px;
}

.post-card {
    padding: 16px;
}

.post-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
}

.name-with-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.verified-badge {
    width: 18px;
    height: 18px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.68rem;
    line-height: 1;
    color: #ffffff;
    background: linear-gradient(135deg, #33b6ff, #0e8df0);
    border: 1px solid #ffffff;
    box-shadow: 0 2px 6px rgba(12, 127, 214, 0.35);
}

.verified-badge.inline-small {
    width: 16px;
    height: 16px;
    font-size: 0.62rem;
}

.post-head-right {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.post-head-right .post-timestamp {
    font-size: 0.8rem;
    white-space: nowrap;
}

/* Ensure icon-btn and mini-btn in post-head are the same height */
.post-head-right .icon-btn,
.post-head-right .mini-btn {
    height: 32px;
    min-width: 32px;
    padding: 0 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    line-height: 1;
    border-radius: 8px;
    flex-shrink: 0;
}

.post-delete-btn {
    color: #a53a2a;
    border-color: #e8b8ae;
    background: #fff2ef;
}

.post-delete-btn:hover {
    background: #ffe7e2;
    color: #8e2c1d;
}

.post-content {
    margin: 10px 0 12px;
    color: #1a3047;
}

.post-image {
    width: 100%;
    max-height: 460px;
    object-fit: cover;
    border-radius: 14px;
    border: 1px solid #d9e5ef;
}

.post-metrics {
    margin-top: 10px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.post-actions {
    margin-top: 8px;
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Forms inside post-actions must not break flex layout */
.post-actions form {
    display: contents; /* form is invisible to flex — button becomes direct flex child */
}

/* All action buttons same size */
.post-actions .icon-btn,
.post-actions > a.icon-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ── Modern post action buttons ── */
.post-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 10px;
    border: none;
    background: transparent;
    border-radius: 999px;
    cursor: pointer;
    color: var(--text-muted, #6b7a8d);
    font-size: 0.82rem;
    font-weight: 500;
    line-height: 1;
    text-decoration: none;
    transition: background 0.15s, color 0.15s, transform 0.1s;
    flex-shrink: 0;
    user-select: none;
    -webkit-user-select: none;
}

.post-action-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    transition: transform 0.15s, stroke 0.15s;
}

.post-action-btn:hover {
    background: var(--action-hover-bg, rgba(100, 120, 200, 0.08));
    color: var(--color-primary, #4a6fa5);
    transform: scale(1.04);
}

.post-action-btn:hover svg {
    transform: scale(1.1);
}

.post-action-btn:active {
    transform: scale(0.97);
}

/* Like button — active = red heart */
.post-action-btn[data-like-button].is-active {
    color: #e0395a;
}

.post-action-btn[data-like-button].is-active svg {
    fill: #e0395a;
    stroke: #e0395a;
}

.post-action-btn[data-like-button]:hover {
    background: rgba(224, 57, 90, 0.08);
    color: #e0395a;
}

/* Repost button — active = teal */
.post-action-btn[data-repost-button].is-active {
    color: #1aab8a;
}

.post-action-btn[data-repost-button].is-active svg {
    stroke: #1aab8a;
}

.post-action-btn[data-repost-button]:hover {
    background: rgba(26, 171, 138, 0.08);
    color: #1aab8a;
}

/* Comment & Share — blue hover */
.post-action-btn.js-share-open:hover {
    background: rgba(74, 111, 165, 0.08);
    color: var(--color-primary, #4a6fa5);
}

.post-action-count {
    font-variant-numeric: tabular-nums;
    min-width: 1ch;
}

.comments-section {
    margin-top: 10px;
    border-top: 1px solid #dce8f2;
    padding-top: 10px;
    display: grid;
    gap: 10px;
}

.comments-list {
    display: grid;
    gap: 8px;
}

.comment-item {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px;
    align-items: flex-start;
}

.comment-item p {
    font-size: 0.9rem;
}

.comment-item small {
    color: var(--text-muted);
    font-size: 0.76rem;
}

.comment-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: center;
}

.comment-form input {
    border-radius: 999px;
    padding: 9px 12px;
}

.send-comment-btn {
    background: linear-gradient(130deg, #1abf94, #0da579);
    color: #ffffff;
}

.suggestions-list,
.notif-list {
    display: grid;
    gap: 10px;
}

.suggestion-item {
    display: flex;
    gap: 10px;
    justify-content: space-between;
    align-items: center;
    background: #f7fbff;
    border: 1px solid #dceaf7;
    border-radius: 14px;
    padding: 10px;
}

.suggestion-user {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.suggestion-item p {
    color: var(--text-muted);
    font-size: 0.82rem;
}

/* Compact suggested profiles: smaller cards, avatar and text for cleaner rail layout */
.suggestions-list .suggestion-item {
    gap: 8px;
    padding: 8px 9px;
    border-radius: 12px;
}

.suggestions-list .suggestion-user {
    gap: 7px;
    min-width: 0;
    flex: 1;
}

.suggestions-list .avatar-small {
    width: 30px;
    height: 30px;
    font-size: 0.72rem;
}

.suggestions-list .name-with-badge {
    font-size: 0.88rem;
    line-height: 1.1;
}

.suggestions-list .suggestion-user .muted {
    display: block;
    font-size: 0.68rem;
    line-height: 1.05;
}

.suggestions-list .suggestion-item p {
    font-size: 0.74rem;
    line-height: 1.15;
    margin-top: 2px;
}

.suggestions-list .mini-btn {
    padding: 6px 10px;
    font-size: 0.74rem;
}

.notif-item {
    border-radius: 13px;
    border: 1px solid #dce7f2;
    background: #f5fbff;
    padding: 10px;
    display: grid;
    gap: 2px;
}

.notif-item.unread {
    border-color: #ffd6cc;
    background: #fff3ef;
}

.center-wrap,
.center-column {
    max-width: 880px;
    margin: 0 auto;
}

.publish-card,
.notifications-page,
.profile-header,
.share-card,
.detail-head {
    padding: 22px;
}

.notif-sections-stack {
    display: grid;
    gap: 12px;
}

.notif-section-card {
    border: 1px solid #dce7f2;
    background: #f8fbff;
    border-radius: 16px;
    padding: 12px;
    display: grid;
    gap: 10px;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}
.notif-section-card .section-head { min-width: 0; }
.notif-section-card .section-head h3 {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}
.notif-item,
.suggestion-item {
    min-width: 0;
    max-width: 100%;
}
.suggestion-item .suggestion-user {
    min-width: 0;
    overflow: hidden;
}
.suggestion-item .suggestion-user p,
.suggestion-item .suggestion-user .name-with-badge,
.suggestion-item .suggestion-user .muted {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.notif-item p {
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.notif-section-head {
    margin-bottom: 0;
}

.notif-section-head h3 {
    font-size: 1rem;
}

.share-card {
    display: grid;
    gap: 14px;
}

.share-link-box {
    display: grid;
    gap: 8px;
}

.share-link-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: center;
}

.row-actions {
    margin-top: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.profile-main {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 14px;
}

.type-pill {
    align-self: center;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    background: #edf2f8;
    border-radius: 999px;
    padding: 4px 8px;
    color: #385069;
}

.notif-list.full .notif-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

/* ── Messaging layout ─────────────────────────────────────── */
.chat-layout {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 12px;
    min-height: 70vh;
}

.chat-sidebar {
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-sidebar-head {
    padding: 16px 16px 0;
    flex-shrink: 0;
}

.contacts-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 10px;
    padding: 0 8px 12px;
    overflow-y: auto;
    flex: 1;
}

/* Custom thin scrollbar for contacts + messages */
.contacts-list,
.messages-list {
    scrollbar-width: thin;
    scrollbar-color: rgba(120, 160, 196, 0.35) transparent;
}
.contacts-list::-webkit-scrollbar,
.messages-list::-webkit-scrollbar {
    width: 4px;
}
.contacts-list::-webkit-scrollbar-thumb,
.messages-list::-webkit-scrollbar-thumb {
    background: rgba(120, 160, 196, 0.35);
    border-radius: 999px;
}

.contact-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 10px 10px;
    border-radius: 12px;
    border: 1px solid transparent;
    background: transparent;
    text-decoration: none;
    color: inherit;
    transition: background 140ms ease, border-color 140ms ease;
}

.contact-item:hover {
    background: rgba(203, 225, 244, 0.35);
    border-color: rgba(168, 205, 234, 0.4);
}

.contact-item.active {
    background: linear-gradient(135deg, rgba(255, 237, 228, 0.9), rgba(255, 218, 202, 0.7));
    border-color: rgba(255, 185, 155, 0.55);
}

.contact-meta {
    min-width: 0;
}

.contact-meta-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 6px;
}

.contact-meta p,
.contact-state-text {
    color: var(--text-muted);
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 1px 0 0;
}

.contact-time {
    color: var(--text-muted);
    font-size: 0.72rem;
    flex-shrink: 0;
}

/* ── Chat main panel ──────────────────────────────────────── */
.chat-main {
    padding: 0;
    display: grid;
    grid-template-rows: auto minmax(320px, 1fr) auto;
    gap: 0;
    overflow: hidden;
}

.chat-header {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(196, 218, 237, 0.5);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.chat-header-user {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
    min-width: 0;
}

.chat-header-meta {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.chat-header-meta h2 {
    font-size: 1rem;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-status {
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* ── Messages list ────────────────────────────────────────── */
.messages-list {
    overflow-y: auto;
    scroll-behavior: smooth;
    padding: 16px 16px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Group spacing: larger gap when sender changes */
.bubble + .bubble.mine,
.bubble.mine + .bubble:not(.mine) {
    margin-top: 8px;
}

/* ── Bubbles ──────────────────────────────────────────────── */
.bubble {
    max-width: min(520px, 82%);
    padding: 9px 13px;
    border-radius: 18px;
    border: none;
    background: rgba(227, 239, 251, 0.85);
    display: flex;
    flex-direction: column;
    gap: 4px;
    animation: bubbleIn 180ms ease both;
    position: relative;
    word-break: break-word;
}

@keyframes bubbleIn {
    from { opacity: 0; transform: translateY(6px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.bubble p {
    margin: 0;
    font-size: 0.93rem;
    line-height: 1.45;
}

/* Tail shapes */
.bubble.theirs {
    align-self: flex-start;
    border-bottom-left-radius: 5px;
    background: rgba(227, 239, 251, 0.85);
}

.bubble.mine {
    align-self: flex-end;
    border-bottom-right-radius: 5px;
    background: linear-gradient(135deg, #ff7f50, #ff6035);
    color: #ffffff;
}

.bubble.mine .bubble-head,
.bubble.mine .bubble-head small {
    color: rgba(255, 255, 255, 0.72);
}

.bubble.mine .attachment-link {
    color: #ffe4d8;
}

/* Hide own name inside own bubbles — it's obvious */
.bubble.mine .bubble-sender-name {
    display: none;
}

.bubble-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    font-size: 0.78rem;
    color: #4e6e88;
    opacity: 0.85;
}

.bubble-head strong {
    font-size: 0.78rem;
    font-weight: 600;
}

.bubble-head small {
    color: var(--text-muted);
    font-size: 0.7rem;
    flex-shrink: 0;
    opacity: 0.8;
}

.attachment-link {
    color: #0f5f91;
    text-decoration: underline;
    font-weight: 600;
    font-size: 0.88rem;
}

/* Bot message slight tint */
.bubble.is-bot-message {
    background: linear-gradient(135deg, rgba(220, 240, 255, 0.92), rgba(205, 232, 252, 0.85));
    border-bottom-left-radius: 5px;
}

/* ── Composer ─────────────────────────────────────────────── */
.chat-form {
    border-top: 1px solid rgba(196, 218, 237, 0.45);
    padding: 10px 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: transparent;
}

#message-text {
    resize: none;
    border: 1px solid rgba(180, 210, 234, 0.7);
    border-radius: 22px;
    padding: 10px 16px;
    font-size: 0.93rem;
    line-height: 1.4;
    background: rgba(240, 248, 255, 0.7);
    transition: border-color 160ms ease, background 160ms ease;
    min-height: 42px;
    max-height: 120px;
    overflow-y: auto;
    width: 100%;
    box-sizing: border-box;
    field-sizing: content;
}

#message-text:focus {
    outline: none;
    border-color: #5fa8d3;
    background: rgba(247, 252, 255, 0.95);
}

.chat-composer-row {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid rgba(180, 210, 234, 0.5);
    background: rgba(240, 248, 255, 0.7);
    color: #3d6b8e;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 140ms ease, transform 120ms ease, color 140ms ease;
    flex-shrink: 0;
    padding: 0;
}

.icon-btn svg {
    width: 18px;
    height: 18px;
}

.icon-btn:hover {
    background: rgba(210, 232, 248, 0.9);
    transform: scale(1.06);
}

.icon-send {
    background: linear-gradient(135deg, #ff7f50, #ff5a2c);
    border-color: transparent;
    color: #ffffff;
    width: 40px;
    height: 40px;
}

.icon-send:hover {
    background: linear-gradient(135deg, #ff6a35, #f04010);
    transform: scale(1.08);
    color: #ffffff;
}

/* ── Empty state ──────────────────────────────────────────── */
.empty-chat,
.empty-state {
    padding: 32px 22px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--text-muted);
}

.empty-chat h2 {
    font-size: 1.1rem;
    color: #2a4a65;
    margin: 0;
}

@media (max-width: 1180px) {
    .layout-grid {
        grid-template-columns: 240px minmax(0, 1fr);
    }

    .right-rail {
        grid-column: 1 / -1;
    }
}

@media (max-width: 900px) {
    .roles-grid {
        grid-template-columns: 1fr;
    }

    .resources-doc-filters {
        grid-template-columns: 1fr;
    }

    .resources-country-row {
        grid-template-columns: 1fr;
    }

    .resources-grid {
        grid-template-columns: 1fr;
    }

    .resources-grid-split {
        grid-template-columns: 1fr;
    }

    .curriculum-controls {
        grid-template-columns: 1fr;
    }

    .resources-doc-filters {
        grid-template-columns: 1fr;
    }

    .north-africa-grid {
        grid-template-columns: 1fr;
    }

    .plan-strip {
        flex-direction: column;
        align-items: flex-start;
    }
}

.auth-with-particles {
    position: relative;
    overflow: hidden;
    border-radius: 22px;
}

.auth-particles {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.auth-with-particles .auth-hero,
.auth-with-particles .auth-card {
    position: relative;
    z-index: 1;
}

.story-link {
    border: none;
    background: transparent;
    padding: 0;
    cursor: pointer;
}

/* Story viewer — old rules removed, see force-override block at end of file */
body.story-open {
    overflow: hidden;
}

.profile-ig-wrap {
    max-width: 980px;
    margin: 0 auto;
    padding: 28px;
}

.ig-profile-header {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 24px;
    align-items: center;
    padding-bottom: 24px;
    border-bottom: 1px solid #d7e4f0;
}

.ig-avatar-col {
    display: grid;
    place-items: center;
}

.ig-avatar-wrap {
    position: relative;
    width: 174px;
    height: 174px;
}

.ig-avatar-shell {
    width: 174px;
    height: 174px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: #d8e4ef;
    padding: 5px;
}

.ig-avatar-shell.has-story {
    background: conic-gradient(from 140deg, #f58529, #dd2a7b, #8134af, #f58529);
}

.ig-avatar-shell.is-seen {
    background: #d8e4ef;
}

.ig-avatar-shell-btn {
    border: none;
    cursor: pointer;
    padding: 0;
}

.ig-avatar {
    width: 164px;
    height: 164px;
    font-size: 2.8rem;
    border: 4px solid #ffffff;
    background: #1e5d8f;
}

.ig-meta-col {
    display: grid;
    gap: 16px;
}

.ig-top-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.ig-username {
    font-size: 1.8rem;
    font-family: "Manrope", sans-serif;
    font-weight: 500;
    margin-right: 8px;
}

.ig-follow-btn {
    padding: 9px 14px;
}

.ig-stat-line {
    display: flex;
    gap: 24px;
    font-size: 0.98rem;
}

.ig-stat-line strong {
    font-weight: 800;
}

.ig-stat-link {
    color: inherit;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border-radius: 10px;
    padding: 2px 7px;
    margin: -2px -7px;
    transition: background 160ms ease, color 160ms ease;
}

.ig-stat-link:hover {
    background: rgba(194, 218, 239, 0.28);
}

.ig-stat-link.active {
    background: rgba(169, 204, 235, 0.4);
    color: #173b58;
}

.profile-connections-wrap {
    margin-top: 10px;
    padding: 12px;
    border: 1px solid #d5e5f3;
    border-radius: 14px;
    background: rgba(246, 251, 255, 0.85);
}

.profile-connections-wrap .suggestions-list {
    max-height: 320px;
    overflow-y: auto;
    padding-right: 2px;
}

.ig-bio-block {
    display: grid;
    gap: 4px;
}

.ig-bio-block strong {
    font-size: 0.92rem;
}

.ig-highlights {
    display: flex;
    gap: 22px;
    padding: 18px 4px 22px;
    overflow-x: auto;
}

.ig-highlight-item {
    display: grid;
    justify-items: center;
    gap: 8px;
    min-width: 74px;
}

.ig-highlight-ring {
    width: 74px;
    height: 74px;
    border-radius: 999px;
    padding: 2px;
    background: #d8e4ef;
    display: grid;
    place-items: center;
}

.ig-highlight-core {
    width: 100%;
    height: 100%;
    border-radius: 999px;
    background: #f4f8fc;
    border: 2px solid #ffffff;
}

.ig-highlight-item small {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.ig-tabs {
    border-top: 1px solid #d7e4f0;
    display: flex;
    justify-content: center;
    gap: 26px;
    margin-top: 4px;
}

.ig-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 14px 0;
    color: #667f99;
    font-size: 0.75rem;
    letter-spacing: 0.8px;
    font-weight: 700;
}

.ig-tab.active {
    color: #1e3145;
    border-top: 1.5px solid #1e3145;
    margin-top: -1px;
}

.ig-post-grid {
    margin-top: 14px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
}

.ig-post-tile {
    position: relative;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: #e8f0f8;
}

.ig-post-tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ig-post-fallback {
    width: 100%;
    height: 100%;
    padding: 14px;
    display: grid;
    place-items: center;
    text-align: center;
    color: #34516b;
    font-size: 0.85rem;
}

.ig-post-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    color: #ffffff;
    font-weight: 700;
    opacity: 0;
    transition: opacity 140ms ease;
}

.ig-post-tile:hover .ig-post-overlay {
    opacity: 1;
}

.ig-empty-grid {
    grid-column: 1 / -1;
    text-align: center;
    padding: 28px;
    color: var(--text-muted);
}

.share-message-box {
    display: grid;
    gap: 8px;
}

.share-contacts-list {
    display: grid;
    gap: 10px;
}

.share-contact-form {
    margin: 0;
}

.share-contact-btn {
    width: 100%;
    border: 1px solid #d8e6f4;
    background: #f7fbff;
    border-radius: 14px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 10px;
    padding: 10px;
    cursor: pointer;
}

.share-contact-btn:hover {
    border-color: #b9d3eb;
    background: #eef6ff;
}

.share-contact-name {
    text-align: left;
    font-weight: 700;
}

.share-send-label {
    color: #1f6aa0;
    font-weight: 700;
}

@media (max-width: 900px) {
    .ig-profile-header {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .ig-avatar-wrap {
        width: 124px;
        height: 124px;
    }

    .ig-avatar-shell {
        width: 124px;
        height: 124px;
    }

    .ig-avatar {
        width: 114px;
        height: 114px;
        font-size: 2rem;
    }

    .ig-stat-line {
        flex-wrap: wrap;
        gap: 14px;
    }

    .ig-post-grid {
        gap: 2px;
    }
}

.share-modal {
    position: fixed;
    inset: 0;
    z-index: 130;
    display: grid;
    place-items: center;
}

.share-modal[hidden] {
    display: none !important;
}

.share-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(7, 16, 26, 0.72);
}

.share-modal-panel {
    position: relative;
    z-index: 1;
    width: min(520px, 94vw);
    max-height: 88vh;
    overflow: auto;
    border-radius: 20px;
    border: 1px solid #d7e5f2;
    background: #ffffff;
    box-shadow: 0 24px 54px rgba(3, 15, 27, 0.32);
    padding: 16px;
    display: grid;
    gap: 12px;
}

.share-modal-head {
    padding-right: 38px;
    display: grid;
    gap: 4px;
}

.share-modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    border: 1px solid #d7e5f2;
    background: #f5f9fd;
    color: #20476b;
    font-weight: 700;
    cursor: pointer;
}

.share-contacts-list-modal {
    max-height: 320px;
    overflow-y: auto;
    padding-right: 2px;
}

.share-contact-btn.sending {
    opacity: 0.7;
}

.share-contact-btn.sent {
    border-color: #b7dfd0;
    background: #edfaf3;
}

.share-contact-btn.sent .share-send-label {
    color: #0f7d58;
}

#share-modal-status,
#resources-share-status {
    min-height: 1.2em;
}

body.theme-light .share-modal-backdrop {
    background: rgba(7, 16, 26, 0.66);
}

body.theme-light .share-modal-panel {
    background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
    border-color: #cfe1f2;
    box-shadow: 0 24px 56px rgba(6, 21, 36, 0.3);
}

body.theme-light .share-modal-close {
    background: #eef5fc;
    border-color: #c9dcef;
    color: #1e4568;
}

body.theme-light .share-modal-panel .share-contact-btn {
    background: #f5faff;
    border-color: #d1e3f4;
}

body.theme-light .share-modal-panel .share-contact-btn:hover {
    background: #ecf5ff;
    border-color: #b8d3ec;
}

body.theme-dark .share-modal-backdrop {
    background: rgba(2, 8, 14, 0.82);
}

body.theme-dark .share-modal-panel {
    background: linear-gradient(180deg, rgba(10, 23, 36, 0.98), rgba(14, 32, 47, 0.96));
    border-color: rgba(112, 154, 191, 0.38);
    box-shadow: 0 28px 58px rgba(0, 0, 0, 0.55);
}

body.theme-dark .share-modal-head h3 {
    color: #f0f7ff;
}

body.theme-dark .share-modal-head p,
body.theme-dark #share-modal-status,
body.theme-dark #resources-share-status {
    color: rgba(204, 222, 240, 0.86);
}

body.theme-dark .share-modal-close {
    background: rgba(18, 39, 57, 0.94);
    border-color: rgba(110, 153, 191, 0.38);
    color: #d9ebff;
}

body.theme-dark .share-modal-panel .share-contact-btn {
    background: rgba(21, 44, 64, 0.94);
    border-color: rgba(109, 152, 189, 0.35);
}

body.theme-dark .share-modal-panel .share-contact-btn:hover {
    background: rgba(27, 54, 78, 0.96);
    border-color: rgba(135, 177, 212, 0.44);
}

body.share-open {
    overflow: hidden;
}




.contact-main-link {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px;
    align-items: center;
    min-width: 0;
    color: inherit;
}

.contact-profile-link {
    white-space: nowrap;
}

.chat-header-user {
    color: inherit;
}

.reaction-strip {
    margin-top: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.reaction-chip {
    border: 1px solid #d5e2ef;
    background: #f6fbff;
    border-radius: 999px;
    padding: 3px 7px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    color: #294a67;
}

.reaction-chip.active {
    border-color: #ffc9b8;
    background: #fff2ec;
    color: #a84831;
}

.quick-react-row {
    margin-top: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    opacity: 0.78;
}

.quick-react-btn {
    border: none;
    background: #edf3f9;
    border-radius: 999px;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.quick-react-btn:hover {
    opacity: 1;
    background: #e3edf7;
}

.audio-message {
    margin-top: 6px;
    width: min(290px, 100%);
}

.emoji-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    border: 1px solid #d8e6f4;
    background: #f5f9fd;
    border-radius: 12px;
    padding: 8px;
}

.emoji-insert-btn {
    border: none;
    background: #ffffff;
    border-radius: 10px;
    width: 34px;
    height: 34px;
    cursor: pointer;
}

.emoji-insert-btn:hover {
    background: #eef5fc;
}

#voice-record-btn.recording {
    background: #ffd7ce;
    color: #9d3925;
    animation: voice-pulse 1s ease infinite;
}

@keyframes voice-pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.07);
    }

    100% {
        transform: scale(1);
    }
}


.contact-item .badge {
    justify-self: end;
}


/* Story viewer advanced controls — rules consolidated in force-override block */

/* Chat layout with always-visible composer */
.chat-layout {
    min-height: calc(100vh - 190px);
    max-height: calc(100vh - 190px);
    align-items: stretch;
}

.chat-sidebar,
.chat-main {
    height: 100%;
}

.chat-sidebar {
    overflow: hidden;
}

.chat-main {
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
}

.messages-list {
    min-height: 0;
    overflow-y: auto;
    padding-bottom: 10px;
    scroll-behavior: smooth;
}

/* Beauty pass for main authenticated pages */
.layout-grid,
.center-wrap,
.chat-layout,
.profile-ig-wrap {
    position: relative;
}

.left-rail,
.right-rail,
.stories-bar-card,
.publish-launch-card,
.post-card,
.publish-card,
.notifications-page,
.chat-sidebar,
.chat-main,
.profile-ig-wrap {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(242, 248, 255, 0.94));
    border-color: rgba(173, 201, 228, 0.45);
    box-shadow: 0 18px 42px rgba(8, 29, 50, 0.18);
}

.left-rail,
.right-rail,
.stories-bar-card,
.publish-launch-card,
.post-card,
.publish-card,
.notifications-page,
.chat-sidebar,
.chat-main,
.profile-ig-wrap,
.suggestion-item,
.notif-item,
.contact-item {
    backdrop-filter: blur(6px);
}

.publish-card h1,
.notifications-page h1,
.chat-header h2,
.profile-ig-wrap .ig-username {
    letter-spacing: 0.2px;
}

.publish-card,
.notifications-page {
    border-radius: 24px;
}

.post-card,
.suggestion-item,
.notif-item,
.contact-item,
.publish-launch-card {
    transition: transform 180ms ease, box-shadow 180ms ease;
}

.post-card:hover,
.suggestion-item:hover,
.notif-item:hover,
.contact-item:hover,
.publish-launch-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 44px rgba(10, 33, 57, 0.2);
}

@media (max-width: 900px) {
    .chat-layout {
        min-height: auto;
        max-height: none;
    }

    .chat-sidebar,
    .chat-main {
        height: auto;
    }

    .chat-main {
        min-height: 70vh;
    }

    .chat-form {
        position: sticky;
        bottom: 8px;
    }
}

body.messages-page {
    overflow: hidden;
}

body.messages-page .page-shell {
    margin-top: 10px;
    margin-bottom: 10px;
}

@media (max-width: 900px) {
    body.messages-page {
        overflow: auto;
    }
}

.publish-sub {
    margin: 8px 0 14px;
    color: #46627d;
}

.notifications-page .eyebrow,
.publish-card .eyebrow {
    margin-bottom: 6px;
}

/* Story viewer interactions */
.story-viewer-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: #10283a;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.story-viewer-actions .mini-btn {
    margin-left: auto;
}

.story-viewers-panel,
.story-share-panel {
    background: #10283a;
    padding: 0 12px 12px;
}

.story-panel-title {
    color: #d9e9fb;
    font-size: 0.8rem;
    font-weight: 700;
    margin: 2px 0 8px;
}

.story-viewers-list {
    display: grid;
    gap: 8px;
    max-height: 160px;
    overflow-y: auto;
}

.story-viewer-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 8px;
    border: 1px solid rgba(157, 186, 214, 0.24);
    border-radius: 12px;
    padding: 7px 8px;
    background: rgba(8, 23, 35, 0.34);
}

.story-viewer-name {
    color: #f3f8ff;
    font-weight: 700;
    font-size: 0.88rem;
}

.story-share-panel textarea {
    border-radius: 12px;
    border: 1px solid #274b67;
    background: #eef6ff;
    margin-bottom: 8px;
}

/* story-share-contacts now styled inside #story-viewer context only */

.story-share-contact.sending {
    opacity: 0.72;
}

.story-share-contact.sent {
    border-color: #2ea37a;
    background: rgba(29, 92, 70, 0.35);
}

.story-share-name {
    text-align: left;
    font-weight: 700;
}

.story-share-label {
    color: #8ac6ff;
    font-weight: 700;
}

#story-share-status {
    display: block;
    margin-top: 8px;
    min-height: 1.2em;
    color: #dcecff;
}

/* Messages page stability: composer remains visible */
body.messages-page {
    overflow: hidden;
}

body.messages-page .footer {
    display: none;
}

body.messages-page .page-shell {
    margin-top: 8px;
    margin-bottom: 8px;
    height: calc(100dvh - 84px);
    display: flex;
}

body.messages-page .chat-layout {
    flex: 1;
    height: 100%;
    min-height: 0;
    max-height: none;
}

body.messages-page .chat-main {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

body.messages-page .messages-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding-bottom: 8px;
}

body.messages-page .chat-form {
    position: sticky;
    bottom: 0;
    margin-top: 8px;
    flex-shrink: 0;
}

@media (max-width: 900px) {
    body.messages-page {
        overflow: auto;
    }

    body.messages-page .footer {
        display: block;
    }

    body.messages-page .page-shell {
        height: auto;
        display: block;
    }

    body.messages-page .chat-layout {
        min-height: 72vh;
    }

    body.messages-page .chat-main {
        min-height: 64vh;
    }
}

/* ── Story viewer — design final (topbar/reply/nav uniquement) ── */

/* Topbar : gradient + user info */
/* Story viewer — old rules removed, see force-override block at end of file */

/* Publish page centered writing */
.publish-card {
    text-align: center;
}

.publish-card .stack-form {
    max-width: 700px;
    margin: 0 auto;
}

.publish-card .stack-form label {
    text-align: center;
}

.publish-card .stack-form textarea,
.publish-card .stack-form input[type="file"] {
    text-align: center;
}

.publish-card .row-actions {
    justify-content: center;
    gap: 12px;
}

/* Edit profile */
.edit-profile-card {
    text-align: left;
    max-width: 640px;
    margin: 0 auto;
}

.edit-profile-card .stack-form {
    gap: 14px;
}

.edit-profile-card .stack-form label {
    text-align: left;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: -6px;
}

.edit-profile-card .stack-form input,
.edit-profile-card .stack-form textarea,
.edit-profile-card .stack-form select {
    text-align: left;
}

.input-readonly {
    opacity: 0.55;
    cursor: not-allowed;
    background: var(--surface) !important;
}

.edit-profile-card .primary-btn {
    width: 100%;
    margin-top: 4px;
}

/* Share modal: add to story action */
.share-story-row {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 10px;
    background: #f4f9ff;
    border: 1px solid #d6e6f6;
    border-radius: 14px;
    padding: 10px;
}

#share-modal-story-btn {
    background: linear-gradient(130deg, #ff6a45, #ff9d52);
    color: #ffffff;
}

#share-modal-story-status {
    min-height: 1.2em;
}

.bg-particles {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.62;
    mix-blend-mode: screen;
}




/* Search and settings pages */
.search-hero-card {
    padding: 18px;
}

.search-main-form {
    margin-top: 10px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
}

.search-layout {
    margin-top: 14px;
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 14px;
    align-items: start;
}

.search-profiles-card {
    padding: 14px;
}

.search-posts-col {
    display: grid;
    gap: 10px;
}

.search-posts-head {
    margin: 0 4px;
}

.settings-card {
    max-width: 760px;
    margin: 0 auto;
    padding: 26px;
    display: grid;
    gap: 12px;
}

@media (max-width: 900px) {
    .search-main-form {
        grid-template-columns: 1fr;
    }

    .search-layout {
        grid-template-columns: 1fr;
    }
}

/* Shared post preview inside messages */
.shared-post-card {
    border: 1px solid #d6e6f5;
    background: #f7fbff;
    border-radius: 12px;
    padding: 10px;
    display: grid;
    gap: 8px;
}

.bubble.mine .shared-post-card {
    background: #fff6f1;
    border-color: #ffd4c5;
}

.shared-post-head {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 8px;
}

.shared-post-head strong {
    font-size: 0.9rem;
}

.shared-post-head small {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.shared-post-text {
    margin: 0;
    color: #1a344f;
    font-size: 0.9rem;
}

.shared-post-image {
    width: 100%;
    max-height: 240px;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid rgba(130, 165, 196, 0.35);
}

.shared-post-open {
    justify-self: start;
}

/* Register roles */
.roles-fieldset {
    border: 1px solid #bfd6ee;
    border-radius: 14px;
    padding: 10px 12px 12px;
    background: linear-gradient(165deg, #f4f9ff 0%, #eef6ff 100%);
    display: grid;
    gap: 8px;
}

.roles-fieldset legend {
    font-size: 0.88rem;
    font-weight: 800;
    color: #26435f;
    padding: 0 4px;
}

.roles-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.role-check {
    display: inline-flex;
    align-items: flex-start;
    gap: 8px;
    border: 1px solid #c9ddf1;
    border-radius: 12px;
    padding: 8px 10px;
    background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
    font-size: 0.9rem;
    font-weight: 700;
    color: #21415f;
    min-width: 0;
}

.role-check input {
    width: auto;
    margin: 0;
    flex-shrink: 0;
    accent-color: #3d87c5;
}

.role-check span {
    display: block;
    min-width: 0;
    line-height: 1.2;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.role-check:has(input:checked) {
    border-color: #4d8ec3;
    background: linear-gradient(160deg, #dff0ff 0%, #eaf6ff 100%);
    color: #0e3d6a;
    box-shadow: 0 0 0 2px rgba(77, 142, 195, 0.25);
}

/* Full-card role selector used in register wizard */
.register-roles-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.role-check-card {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0;
    cursor: pointer;
    transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.role-check-card input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.role-card-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 16px 10px 14px;
    text-align: center;
}

.role-card-icon {
    font-size: 1.8rem;
    line-height: 1;
}

.role-card-label {
    font-size: 0.92rem;
    font-weight: 800;
    color: #1b4268;
}

.role-card-desc {
    font-size: 0.74rem;
    font-weight: 500;
    color: #5580a0;
    line-height: 1.35;
}

.role-check-card:has(input:checked) {
    border-color: #4d8ec3;
    background: linear-gradient(160deg, #dff0ff 0%, #eaf6ff 100%);
    box-shadow: 0 0 0 2px rgba(77, 142, 195, 0.3);
}

.role-check-card:has(input:checked) .role-card-label {
    color: #0d3a65;
}

.role-check-card:has(input:checked) .role-card-desc {
    color: #2d608f;
}

/* Dark auth background — role cards */
body.auth-body .role-check-card .role-card-label {
    color: #b8dcf8;
}

body.auth-body .role-check-card .role-card-desc {
    color: rgba(168, 206, 236, 0.75);
}

body.auth-body .role-check-card:has(input:checked) .role-card-label {
    color: #c8e8ff;
}

body.auth-body .role-check-card:has(input:checked) .role-card-desc {
    color: rgba(180, 218, 245, 0.9);
}

@media (max-width: 560px) {
    .register-roles-grid {
        grid-template-columns: 1fr;
    }
    .role-card-inner {
        flex-direction: row;
        text-align: left;
        padding: 12px 14px;
    }
    .role-card-icon {
        font-size: 1.4rem;
    }
}

body.theme-dark .roles-fieldset {
    border-color: #3d607d;
    background: linear-gradient(165deg, rgba(18, 43, 64, 0.92), rgba(17, 39, 58, 0.88));
}

body.theme-dark .roles-fieldset legend {
    color: #d4e9fb;
}

body.theme-dark .role-check {
    border-color: #456b8a;
    background: linear-gradient(180deg, rgba(24, 52, 75, 0.92), rgba(20, 46, 68, 0.9));
    color: #ddedfb;
}

body.theme-dark .role-check input {
    accent-color: #72b7e8;
}

body.theme-dark .role-check:has(input:checked) {
    border-color: #5da0d4;
    background: linear-gradient(160deg, rgba(30, 72, 110, 0.9), rgba(22, 58, 92, 0.88));
    color: #c8e8ff;
    box-shadow: 0 0 0 2px rgba(93, 160, 212, 0.3);
}

/* Roles on the dark auth registration page */
body.auth-body .roles-fieldset {
    border-color: rgba(138, 181, 216, 0.3);
    background: rgba(10, 27, 44, 0.55);
}

body.auth-body .roles-fieldset legend,
body.auth-body .roles-fieldset .muted {
    color: rgba(204, 226, 245, 0.82);
}

body.auth-body .role-check {
    border-color: rgba(130, 175, 212, 0.3);
    background: rgba(14, 36, 56, 0.6);
    color: #cce5fb;
}

body.auth-body .role-check input {
    accent-color: #78b8e8;
}

body.auth-body .role-check:has(input:checked) {
    border-color: #5da0d4;
    background: linear-gradient(160deg, rgba(28, 68, 106, 0.88), rgba(20, 55, 88, 0.85));
    color: #c8e8ff;
    box-shadow: 0 0 0 2px rgba(93, 160, 212, 0.35);
}

/* Resources page */
.resources-page {
    padding: 16px;
    display: grid;
    gap: 10px;
}

.resources-roles-line {
    margin: 0;
    color: #214361;
}

.resources-pricing-note {
    margin: 0;
}

.plan-strip {
    border: 1px solid #d4e3f2;
    border-radius: 14px;
    background: linear-gradient(130deg, #f6fbff 0%, #eef6ff 100%);
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.plan-title {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 800;
    color: #173c5e;
}

.plan-price {
    font-size: 0.96rem;
    font-weight: 800;
    color: #103f67;
    background: #e8f2ff;
    border: 1px solid #cfe3fa;
    border-radius: 999px;
    padding: 6px 10px;
    white-space: nowrap;
}

.resources-limit-note {
    margin-top: 0;
}

.resources-active-note {
    color: #1f6a43;
}

.resources-country-form {
    display: grid;
    gap: 8px;
}

.resources-country-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
}

.resources-grid {
    margin-top: 14px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    align-items: start;
}

.resources-grid-split {
    grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.95fr);
}

.resources-side-stack {
    display: flex;
    flex-direction: column;
    gap: 14px;
    align-self: start;
}

.resources-side-stack > .resources-card {
    height: auto;
}

.resources-card {
    padding: 14px;
}

.resources-list,
.resources-offers-stack {
    display: grid;
    gap: 10px;
}

.resource-item,
.offer-item {
    border: 1px solid #d9e7f5;
    border-radius: 12px;
    background: #f8fbff;
    padding: 10px;
    display: grid;
    gap: 6px;
}

.resource-item h4,
.offer-item h4 {
    margin: 0;
    font-size: 0.95rem;
}

.offer-head {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
}

.resources-offer-form {
    margin-bottom: 14px;
}

.resources-inline-form {
    margin-top: 8px;
}

.resources-market-card {
    margin-top: 14px;
    padding: 14px;
}

.resources-curriculum,
.resources-doc-library,
.north-africa-map {
    margin-top: 12px;
    border: 1px solid #d9e7f5;
    border-radius: 14px;
    background: #f8fbff;
    padding: 12px;
    display: grid;
    gap: 10px;
}

.resources-doc-filters {
    display: grid;
    grid-template-columns: minmax(0, 210px) minmax(0, 150px) minmax(0, 1fr) minmax(0, 1.2fr);
    gap: 10px;
    align-items: end;
}

.resources-doc-filters input[type="search"] {
    width: 100%;
    border: 1px solid #c5d9ec;
    border-radius: 10px;
    background: #ffffff;
    color: #173f61;
    padding: 9px 10px;
}

.resources-doc-filters input[type="search"]::placeholder {
    color: #6d89a3;
}

.resources-doc-type-tabs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.resources-doc-type-tabs .mini-btn {
    border: 1px solid #c5d9ec;
}

.resources-doc-type-tabs .mini-btn.is-active {
    background: #1d496d;
    border-color: #1d496d;
    color: #ffffff;
}

.resources-doc-list {
    display: grid;
    gap: 10px;
}

.resource-doc-item {
    border: 1px solid #d9e7f5;
    border-radius: 12px;
    background: #ffffff;
    padding: 10px;
    display: grid;
    gap: 6px;
}

.resource-doc-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.resource-doc-head h5 {
    margin: 0;
    font-size: 0.92rem;
    color: #173f61;
}

.resource-doc-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
}

.resource-doc-inline {
    margin: 0;
    font-size: 0.8rem;
}

.resource-doc-open {
    width: fit-content;
}

.resource-doc-open[disabled],
.resource-doc-open.is-disabled,
.resource-doc-open[aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.resource-allo-subject {
    border: 1px solid #cfe1f3;
    border-radius: 14px;
    background: #f9fcff;
    padding: 10px;
    display: grid;
    gap: 10px;
}

.resource-allo-subject-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.resource-allo-subject-head h5 {
    margin: 0;
    font-size: 0.95rem;
    color: #144160;
}

.resource-allo-years {
    display: grid;
    gap: 10px;
}

.resource-allo-year-block {
    border: 1px solid #d7e6f5;
    border-radius: 12px;
    background: #ffffff;
    padding: 8px;
    display: grid;
    gap: 8px;
}

.resource-allo-year-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.resource-allo-year-head h6 {
    margin: 0;
    font-size: 0.86rem;
    color: #1a496c;
}

.resource-allo-year-list {
    display: grid;
    gap: 8px;
}

.resource-allo-year-list .resource-doc-item {
    margin: 0;
}

.resources-pdf-viewer {
    position: fixed;
    inset: 0;
    z-index: 240;
    margin: 0;
    border: none;
    border-radius: 0;
    background: rgba(7, 16, 26, 0.96);
    padding: 12px;
    display: grid;
    grid-template-rows: auto 1fr;
    gap: 10px;
}

.resources-pdf-viewer[hidden] {
    display: none !important;
}

body.resources-pdf-only {
    overflow: hidden;
}

.resources-pdf-viewer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border: 1px solid #2a587c;
    border-radius: 12px;
    background: rgba(14, 32, 47, 0.92);
    padding: 8px 10px;
}

.resources-pdf-viewer-head h5 {
    margin: 0;
    font-size: 0.9rem;
    color: #f0f8ff;
}

#resources-pdf-frame {
    width: 100%;
    height: calc(100vh - 90px);
    min-height: 0;
    border: 1px solid #d9e7f5;
    border-radius: 12px;
    background: #f8fbff;
}


.curriculum-controls {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.curriculum-controls label {
    display: grid;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: 700;
    color: #1d4364;
}

.curriculum-subjects-wrap {
    display: grid;
    gap: 8px;
}

.curriculum-subjects-title {
    margin: 0;
    font-size: 0.86rem;
    font-weight: 800;
    color: #164466;
}

.curriculum-subjects {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.curriculum-subject-pill,
.curriculum-track-pill {
    display: inline-flex;
    align-items: center;
    border: 1px solid #cfe3f7;
    border-radius: 999px;
    background: #edf5ff;
    padding: 5px 10px;
    font-size: 0.78rem;
    font-weight: 700;
    color: #1b4d74;
}

.resource-scope-pill {
    background: #ffe6cc;
    border-color: #ffc28b;
    color: #8a3f10;
}

.resource-subject-pill {
    background: #e8f7e8;
    border-color: #a9ddb0;
    color: #1f6b2b;
    font-weight: 800;
    white-space: nowrap;
}

.resource-session-pill {
    background: #dff0ff;
    border-color: #9cccf3;
    color: #0f4774;
}

.resource-correction-pill {
    background: #e5f8eb;
    border-color: #96d7a9;
    color: #176635;
}

.resource-missing-pill {
    background: #ffe9e9;
    border-color: #f2aaaa;
    color: #8a2a2a;
}

.curriculum-region-block {
    display: grid;
    gap: 8px;
    margin-top: 6px;
}

.curriculum-region-title {
    margin: 0;
    font-size: 0.9rem;
    color: #173f62;
}

.north-africa-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.na-country-card {
    border: 1px solid #d9e7f5;
    border-radius: 12px;
    background: #fdfefe;
    padding: 10px;
    display: grid;
    gap: 8px;
}

.na-country-card h5 {
    margin: 0;
    color: #163f60;
}

.curriculum-track-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.checkout-card {
    padding: 16px;
    display: grid;
    gap: 12px;
}

.checkout-summary {
    border: 1px solid #d7e7f8;
    border-radius: 14px;
    padding: 12px;
    background: #f7fbff;
    display: grid;
    gap: 6px;
}

.checkout-summary p {
    margin: 0;
}

.checkout-price {
    font-weight: 800;
    color: #0f4d7a;
}

.checkout-active {
    color: #1f6a43;
}

@media (max-width: 900px) {
    .roles-grid {
        grid-template-columns: 1fr;
    }

    .resources-country-row {
        grid-template-columns: 1fr;
    }

    .resources-grid {
        grid-template-columns: 1fr;
    }
    .resources-side-stack {
        align-self: stretch;
    }

    .curriculum-controls {
        grid-template-columns: 1fr;
    }

    .resources-doc-filters {
        grid-template-columns: 1fr;
    }

    .north-africa-grid {
        grid-template-columns: 1fr;
    }

    .plan-strip {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Profile role and country lines */
.ig-role-line {
    margin: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    color: #255076;
    font-weight: 700;
    background: #e9f3ff;
    border: 1px solid #c9deef;
    border-radius: 999px;
    padding: 4px 10px;
    width: fit-content;
}

.ig-country-line {
    margin: 0;
    font-size: 0.86rem;
    color: #2f5a7f;
}

.ig-bio-text {
    white-space: pre-line;
}






/* Profile privacy and settings expansion */
.ig-private-pill,
.search-private-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.2px;
    background: #eaf2fb;
    color: #32587b;
    border: 1px solid #c8ddef;
}

.ig-email-line {
    margin: 0;
    color: #345574;
    font-size: 0.9rem;
}

.profile-plan-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.plan-chip {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 6px 10px;
    border: 1px solid #cde2f5;
    background: #edf6ff;
    color: #1c4970;
    font-size: 0.76rem;
    font-weight: 700;
}

.ig-reposts-wrap {
    margin-top: 18px;
    display: grid;
    gap: 8px;
}

.ig-private-state {
    margin-top: 18px;
    border: 1px dashed #c8ddef;
    border-radius: 16px;
    padding: 20px;
    text-align: center;
    background: #f6fbff;
}

.ig-private-state h3 {
    margin-bottom: 6px;
}

.settings-shell {
    display: grid;
    gap: 14px;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.settings-hero {
    max-width: none;
}

.settings-panel {
    max-width: none;
    gap: 14px;
}

.settings-overview-list {
    margin: 0;
    display: grid;
    gap: 10px;
}

.settings-overview-list div {
    display: grid;
    gap: 2px;
}

.settings-overview-list dt {
    color: #4d6f8f;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.settings-overview-list dd {
    margin: 0;
    color: #1b3f62;
    font-weight: 700;
}

.settings-form {
    gap: 10px;
}

.switch-row {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px;
    align-items: center;
    border: 1px solid #d6e6f5;
    border-radius: 12px;
    padding: 10px;
    background: #f8fcff;
    color: #1f4263;
    font-weight: 700;
}

.switch-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

@media (max-width: 980px) {
    .settings-grid {
        grid-template-columns: 1fr;
    }
}

/* Student profile controls */
.student-fieldset {
    margin-top: 6px;
}

.student-subjects-grid {
    display: grid;
    gap: 8px;
}

.student-subject-row {
    display: grid;
    grid-template-columns: 1.3fr minmax(0, 0.7fr);
    gap: 8px;
}

.student-progress-card {
    margin-top: 10px;
    border: 1px solid #d7e6f4;
    border-radius: 14px;
    background: #f7fbff;
    padding: 10px;
    display: grid;
    gap: 8px;
}

.student-progress-title {
    margin: 0;
    font-weight: 800;
    color: #1d4569;
}

.student-progress-meta {
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.77rem;
    color: #467195;
}

.student-progress-meta span {
    border: 1px solid #c9dced;
    background: #eef6fc;
    border-radius: 999px;
    padding: 3px 8px;
    font-weight: 700;
}

.student-system-line {
    margin: 2px 0 8px;
}

.student-grade-hint {
    margin: 2px 0 6px;
    color: #325f84;
    font-weight: 700;
}

.student-progress-row {
    display: grid;
    gap: 5px;
}

.student-progress-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.88rem;
    color: #1f4668;
}

.student-progress-track {
    width: 100%;
    height: 10px;
    border-radius: 999px;
    background: #dce8f3;
    overflow: hidden;
}

.student-progress-track span {
    display: block;
    height: 100%;
    border-radius: 999px;
}

.student-color-1 .student-progress-track span {
    background: linear-gradient(90deg, #2f8ad8, #5fa7e5);
}

.student-color-2 .student-progress-track span {
    background: linear-gradient(90deg, #f18f45, #f2b15a);
}

.student-color-3 .student-progress-track span {
    background: linear-gradient(90deg, #2aa96b, #69c98f);
}

@media (max-width: 760px) {
    .student-subject-row {
        grid-template-columns: 1fr;
    }
}


/* Language switcher */
.lang-switcher-form {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid rgba(193, 216, 236, 0.28);
    border-radius: 999px;
    padding: 4px 8px;
    background: rgba(8, 22, 36, 0.42);
}

.lang-switcher-label {
    font-size: 0.75rem;
    color: #bcd9f4;
    font-weight: 700;
}

.lang-switcher-select {
    border: none;
    background: transparent;
    color: #e8f1ff;
    font-weight: 700;
    font-size: 0.86rem;
    padding: 0 4px;
    min-width: 112px;
    outline: none;
}

.lang-switcher-select option {
    color: #153a59;
}

html[dir="rtl"] .topbar-inner {
    direction: rtl;
}

html[dir="rtl"] .top-nav {
    flex-direction: row-reverse;
}

/* Profile highlights + Story archives */
.ig-highlight-core img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 999px;
    display: block;
}

.ig-highlight-add {
    text-decoration: none;
    color: inherit;
}

.ig-highlight-ring-add {
    background: #d8e4ef;
}

.ig-highlight-core-add {
    display: grid;
    place-items: center;
    font-size: 2rem;
    color: #2f567b;
    font-weight: 500;
}

.story-archives-wrap {
    max-width: 1020px;
}

.story-archives-card {
    display: grid;
    gap: 14px;
}

.story-archives-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}

.story-archive-item {
    border: 1px solid #d4e5f4;
    border-radius: 16px;
    background: #f8fcff;
    overflow: hidden;
}

.story-archive-preview {
    aspect-ratio: 9 / 16;
    background: #e7f1fa;
}

.story-archive-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.story-archive-expired-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #eef3f7;
    color: #90a8bc;
    font-size: 0.78rem;
    font-style: italic;
}

.story-archive-meta {
    padding: 10px;
    display: grid;
    gap: 10px;
}

.story-archive-time {
    margin: 0;
    font-size: 0.82rem;
    color: #45627d;
}

.story-archive-actions {
    display: grid;
    gap: 8px;
}

.story-archive-actions input[type="text"] {
    width: 100%;
}

.danger-btn {
    border: 1px solid #f0c3c3;
    background: #fff1f1;
    color: #8d3535;
}
/* Theme modes */
body.theme-light {
    --bg: #f3f7fc;
    --surface: rgba(255, 255, 255, 0.96);
    --text: #13253a;
    --text-muted: #4c6279;
    --border: rgba(20, 42, 68, 0.12);
    --accent: #ff6a45;
    --shadow: 0 20px 40px rgba(20, 46, 72, 0.14);
    background: linear-gradient(160deg, #f3f7fc 0%, #e9f1f9 46%, #dde9f4 100%);
}

body.theme-dark {
    --bg: #08131f;
    --surface: rgba(12, 25, 38, 0.88);
    --text: #e8f3ff;
    --text-muted: #a8bfd8;
    --border: rgba(141, 178, 210, 0.2);
    --accent: #ff6a45;
    --shadow: 0 24px 50px rgba(2, 9, 16, 0.45);
    background: linear-gradient(160deg, #08131f 0%, #0d2439 42%, #12324b 100%);
}

body.theme-light .topbar {
    background: rgba(255, 255, 255, 0.86);
    border-bottom: 1px solid rgba(43, 73, 102, 0.12);
}

body.theme-light .brand-text {
    color: #163b5e;
}

body.theme-light .top-nav > a,
body.theme-light .top-nav button {
    color: #214969;
}

body.theme-light .top-nav > a:hover,
body.theme-light .top-nav button:hover {
    background: rgba(35, 73, 105, 0.12);
}

body.theme-light .top-nav-icon {
    background: #edf4fb;
    border-color: #cbdced;
    color: #214969;
}

body.theme-light .top-nav-avatar,
body.theme-light .top-nav-avatar-fallback {
    border-color: #c8d8ea;
    background: #e9f2fb;
    color: #1f4e77;
}

body.theme-light .footer {
    color: #4b6380;
}

body.theme-light .bg-grid {
    background-image: linear-gradient(rgba(41, 72, 103, 0.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(41, 72, 103, 0.08) 1px, transparent 1px);
}

/* Stories: show username + publish time */
.story-meta {
    display: grid;
    gap: 2px;
    justify-items: center;
}

.story-time {
    font-size: 0.68rem;
    color: #bdd2e7;
    font-weight: 600;
    line-height: 1;
}

/* Settings redesign (Insta/TikTok style sections) */
.settings-modern-shell {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 14px;
    align-items: start;
}

.settings-menu-card {
    position: sticky;
    top: 88px;
    padding: 16px;
    display: grid;
    gap: 10px;
}

.settings-menu-nav {
    display: grid;
    gap: 8px;
}

.settings-menu-nav a {
    border: 1px solid #d5e4f2;
    background: #f6fbff;
    border-radius: 12px;
    padding: 9px 11px;
    font-weight: 700;
    color: #214969;
}

.settings-menu-nav a:hover {
    background: #eaf4ff;
}

.settings-modern-content {
    display: grid;
    gap: 14px;
}

.settings-section-card {
    padding: 16px;
    display: grid;
    gap: 12px;
}

.settings-divider {
    border: 0;
    border-top: 1px solid #d7e6f3;
    margin: 2px 0;
}

.settings-activity-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.settings-add-account-form {
    gap: 8px;
}

.settings-account-list {
    display: grid;
    gap: 10px;
}

.settings-account-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border: 1px solid #d4e3f1;
    border-radius: 14px;
    padding: 10px;
    background: linear-gradient(180deg, #fbfdff, #f2f8ff);
}

.settings-account-item.is-current {
    border-color: #ebb39a;
    background: linear-gradient(130deg, #fff2ec, #ffe8dd);
}

.settings-account-main {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.settings-account-avatar {
    width: 46px;
    height: 46px;
    border-radius: 999px;
    border: 1px solid #d2e3f2;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    flex-shrink: 0;
    color: #21486a;
    font-weight: 800;
}

.settings-account-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.settings-account-meta {
    min-width: 0;
    display: grid;
    gap: 2px;
}

.settings-account-meta p {
    margin: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #1c476b;
}

.settings-account-meta small {
    color: #567899;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.settings-account-switch-form {
    flex-shrink: 0;
}

.theme-choice-fieldset {
    border: 1px solid #d2e4f4;
    border-radius: 12px;
    padding: 10px;
    display: grid;
    gap: 8px;
}

.theme-choice-fieldset legend {
    padding: 0 6px;
    font-weight: 800;
    color: #285071;
}

.theme-choice-option {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    color: #214869;
}

.settings-logout-card {
    border-color: #f0caca;
    background: #fff9f9;
}

@media (max-width: 960px) {
    .settings-modern-shell {
        grid-template-columns: minmax(0, 1fr);
    }

    .settings-menu-card {
        position: static;
    }
}

body.theme-dark input,
body.theme-dark textarea,
body.theme-dark select {
    background: #12263a;
    color: #e8f3ff;
    border-color: #3b5875;
}

body.theme-dark input::placeholder,
body.theme-dark textarea::placeholder {
    color: rgba(179, 203, 226, 0.78);
}


body.theme-dark .top-nav-icon {
    background: rgba(22, 45, 67, 0.9);
    border-color: #3c607f;
    color: #e8f3ff;
}

body.theme-dark .top-nav-avatar,
body.theme-dark .top-nav-avatar-fallback {
    border-color: #50779a;
    background: #1a3a57;
    color: #e8f3ff;
}
body.theme-dark .mini-btn {
    background: #16324a;
    color: #e8f3ff;
}


body.theme-dark .profile-icon-btn {
    background: linear-gradient(180deg, #162d43, #12263a);
    border-color: #3c607f;
    color: #e8f3ff;
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.3);
}

body.theme-dark .profile-icon-btn:hover {
    background: linear-gradient(180deg, #1b3650, #163049);
}

body.theme-dark .profile-icon-badge {
    border-color: #102131;
}

body.theme-dark .settings-menu-nav a {
    background: #12263a;
    border-color: #355470;
    color: #e1effd;
}

body.theme-dark .switch-row {
    background: #13293d;
    border-color: #35526c;
    color: #e8f3ff;
}

body.theme-dark .theme-choice-fieldset {
    border-color: #35526c;
}

body.theme-dark .settings-divider {
    border-top-color: #35526c;
}

body.theme-dark .settings-logout-card {
    background: rgba(74, 28, 38, 0.45);
    border-color: #744756;
}

body.theme-dark .danger-btn {
    background: #4a2630;
    color: #ffd8dd;
    border-color: #8a5560;
}
body.theme-dark .theme-choice-option {
    color: #e8f3ff;
}

body.theme-dark .settings-menu-nav a:hover {
    background: #18354f;
}
/* Final polish: complete dark mode coverage + settings controls + chatbot UI */
.settings-menu-nav a,
.theme-choice-option span,
.switch-row,
.bot-prompt-btn,
.bot-helper-card {
    transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.settings-menu-nav a {
    background: linear-gradient(180deg, #f9fcff, #eef5ff);
    border: 1px solid #cfe1f1;
    box-shadow: 0 8px 18px rgba(18, 48, 75, 0.08);
}

.settings-menu-nav a:hover {
    background: linear-gradient(180deg, #f2f8ff, #e7f1ff);
}

.settings-menu-nav a:focus-visible,
.theme-choice-option input[type="radio"]:focus-visible + span,
.settings-form .lang-switcher-select:focus-visible,
.switch-row input[type="checkbox"]:focus-visible {
    outline: 2px solid rgba(38, 111, 173, 0.45);
    outline-offset: 2px;
}

.settings-form .lang-switcher-select {
    border: 1px solid #c8d9eb;
    background: linear-gradient(180deg, #ffffff, #f4f9ff);
    color: #1d476c;
    border-radius: 12px;
    padding: 10px 12px;
    min-width: 220px;
}

.settings-form .lang-switcher-select option {
    color: #143857;
}

.theme-choice-fieldset {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    background: linear-gradient(180deg, #fafdff, #f1f7ff);
}

.theme-choice-option {
    display: block;
    margin: 0;
}

.theme-choice-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.theme-choice-option span {
    display: inline-flex;
    width: 100%;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid #d2e3f3;
    border-radius: 12px;
    background: #ffffff;
    color: #20496d;
    font-weight: 800;
    letter-spacing: 0.2px;
}

.theme-choice-option span::before {
    content: "";
    width: 11px;
    height: 11px;
    border-radius: 999px;
    border: 2px solid #9eb9d2;
    background: transparent;
}

.theme-choice-option input[type="radio"]:checked + span {
    border-color: #f7a88f;
    background: linear-gradient(130deg, #ffece4, #ffe0d4);
    color: #9f462e;
}

.theme-choice-option input[type="radio"]:checked + span::before {
    border-color: #c85f40;
    background: #e26944;
}

.switch-row {
    grid-template-columns: auto 1fr;
    gap: 12px;
    border: 1px solid #d4e3f2;
    background: linear-gradient(180deg, #fbfdff, #f3f8ff);
}

.switch-row input[type="checkbox"] {
    appearance: none;
    width: 42px;
    height: 24px;
    margin: 0;
    border-radius: 999px;
    border: 1px solid #b8cee2;
    background: #dce9f4;
    position: relative;
    cursor: pointer;
}

.switch-row input[type="checkbox"]::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    background: #ffffff;
    box-shadow: 0 2px 6px rgba(16, 36, 55, 0.2);
    transition: transform 160ms ease;
}

.switch-row input[type="checkbox"]:checked {
    border-color: #eb9b80;
    background: linear-gradient(130deg, #ff885f, #ff6a45);
}

.switch-row input[type="checkbox"]:checked::after {
    transform: translateX(18px);
}

.chat-head-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.bot-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 18px;
    border-radius: 999px;
    padding: 0 6px;
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.3px;
    color: #ffffff;
    background: linear-gradient(130deg, #19be95, #0f9c7a);
}

.bot-helper-card {
    border: 1px solid #cbe2f3;
    border-radius: 14px;
    padding: 10px;
    background: linear-gradient(140deg, #f7fcff, #edf6ff);
    display: grid;
    gap: 8px;
}

.bot-helper-card p {
    margin: 0;
    color: #264c6f;
    font-weight: 700;
    font-size: 0.86rem;
}

.bot-prompt-row {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.bot-prompt-btn {
    border: 1px solid #c8ddef;
    border-radius: 999px;
    background: #ffffff;
    color: #20476a;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 7px 10px;
    cursor: pointer;
}

.bot-prompt-btn:hover {
    border-color: #a7c6e0;
    background: #edf6ff;
    transform: translateY(-1px);
}

body.theme-dark .left-rail,
body.theme-dark .right-rail,
body.theme-dark .stories-bar-card,
body.theme-dark .publish-launch-card,
body.theme-dark .post-card,
body.theme-dark .publish-card,
body.theme-dark .notifications-page,
body.theme-dark .chat-sidebar,
body.theme-dark .chat-main,
body.theme-dark .profile-ig-wrap,
body.theme-dark .resources-page,
body.theme-dark .resources-card,
body.theme-dark .resources-market-card,
body.theme-dark .settings-menu-card,
body.theme-dark .settings-section-card {
    background: linear-gradient(180deg, rgba(10, 22, 34, 0.96), rgba(15, 32, 47, 0.92));
    border-color: rgba(128, 165, 198, 0.3);
    box-shadow: 0 24px 52px rgba(1, 8, 14, 0.5);
}

body.theme-dark .settings-menu-nav a {
    background: linear-gradient(180deg, #162d43, #12263a);
    border-color: #3c607f;
    color: #e8f3ff;
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.3);
}

body.theme-dark .settings-menu-nav a:hover {
    background: linear-gradient(180deg, #1b3650, #163049);
}

body.theme-dark .stats-row > div,
body.theme-dark .suggestion-item,
body.theme-dark .notif-item,
body.theme-dark .notif-section-card,
body.theme-dark .contact-item,
body.theme-dark .share-contact-btn,
body.theme-dark .resource-item,
body.theme-dark .offer-item,
body.theme-dark .checkout-summary,
body.theme-dark .student-progress-card,
body.theme-dark .plan-strip,
body.theme-dark .shared-post-card,
body.theme-dark .story-archive-item,
body.theme-dark .settings-account-item,
body.theme-dark .resources-curriculum,
body.theme-dark .north-africa-map,
body.theme-dark .na-country-card,
body.theme-dark .curriculum-subject-pill,
body.theme-dark .curriculum-track-pill {
    background: rgba(18, 39, 57, 0.88);
    border-color: rgba(127, 165, 198, 0.34);
    color: var(--text);
}


body.theme-dark .settings-account-item.is-current {
    background: rgba(101, 56, 39, 0.48);
    border-color: rgba(255, 162, 123, 0.46);
}

body.theme-dark .settings-account-avatar {
    background: rgba(18, 39, 56, 0.92);
    border-color: rgba(118, 157, 190, 0.34);
    color: #e8f3ff;
}

body.theme-dark .settings-account-meta p {
    color: #e8f3ff;
}

body.theme-dark .settings-account-meta small {
    color: #a8c0d8;
}

body.theme-dark .notif-item.unread {
    background: rgba(100, 50, 36, 0.36);
    border-color: rgba(255, 146, 108, 0.5);
}

body.theme-dark .contact-item.active {
    background: rgba(105, 58, 40, 0.36);
    border-color: rgba(255, 159, 120, 0.5);
}

body.theme-dark .section-head a {
    color: #9ad2ff;
}

body.theme-dark.edit-profile-page .edit-profile-card .stack-form label {
    color: #d6eafd;
}

body.theme-dark.edit-profile-page .edit-profile-card .muted,
body.theme-dark.edit-profile-page .edit-profile-card .student-grade-hint {
    color: #a8c5de;
}

body.theme-dark.edit-profile-page .edit-profile-card input[readonly] {
    background: rgba(16, 39, 58, 0.92);
    border-color: rgba(108, 148, 182, 0.42);
    color: #d8e9f9;
}

body.theme-dark .post-content,
body.theme-dark .shared-post-text,
body.theme-dark .resources-roles-line,
body.theme-dark .checkout-price,
body.theme-dark .plan-title,
body.theme-dark .student-progress-title,
body.theme-dark .settings-overview-list dd {
    color: #e9f4ff;
}

body.theme-dark .settings-overview-list dt {
    color: #9fbdd8;
}

body.theme-dark .plan-price {
    background: rgba(35, 67, 94, 0.92);
    border-color: rgba(128, 166, 198, 0.36);
    color: #d9ecff;
}

body.theme-dark .resources-active-note,
body.theme-dark .checkout-active {
    color: #7ad8af;
}

body.theme-dark .post-image,
body.theme-dark .shared-post-image,
body.theme-dark .student-progress-track {
    border-color: rgba(119, 158, 190, 0.35);
}

body.theme-dark .comments-section,
body.theme-dark .chat-header,
body.theme-dark .chat-form,
body.theme-dark .ig-profile-header,
body.theme-dark .ig-tabs,
body.theme-dark .settings-divider {
    border-color: rgba(123, 161, 194, 0.3);
}

body.theme-dark .chat-form {
    background: linear-gradient(180deg, rgba(16, 35, 52, 0.96), rgba(11, 27, 41, 0.96));
}

body.theme-dark .bubble {
    background: rgba(28, 52, 72, 0.88);
    border: none;
    color: #e9f4ff;
}

body.theme-dark .bubble.theirs {
    background: rgba(28, 52, 72, 0.88);
}

body.theme-dark .bubble.mine {
    background: linear-gradient(135deg, #c95c32, #b04520);
    color: #ffffff;
}

body.theme-dark .bubble.is-bot-message {
    background: rgba(18, 44, 68, 0.92);
}

body.theme-dark .bubble-head,
body.theme-dark .ig-country-line,
body.theme-dark .ig-email-line,
body.theme-dark .student-progress-head,
body.theme-dark .student-progress-meta {
    color: #c8ddf1;
}

body.theme-dark #message-text {
    background: rgba(16, 34, 52, 0.7);
    border-color: rgba(100, 145, 183, 0.4);
    color: #e2f0fc;
}

body.theme-dark #message-text:focus {
    border-color: #5a9fca;
    background: rgba(20, 42, 62, 0.9);
}

body.theme-dark #message-text::placeholder {
    color: rgba(160, 195, 225, 0.5);
}

body.theme-dark .icon-btn {
    background: rgba(22, 46, 67, 0.8);
    border-color: rgba(100, 145, 183, 0.35);
    color: #b8d5ee;
}

body.theme-dark .icon-btn:hover {
    background: rgba(32, 60, 85, 0.9);
}

body.theme-dark .post-action-btn {
    color: #8aafc8;
}

body.theme-dark .post-action-btn:hover {
    background: rgba(100, 145, 183, 0.12);
    color: #b8d5ee;
}

body.theme-dark .post-action-btn[data-like-button].is-active,
body.theme-dark .post-action-btn[data-like-button]:hover {
    background: rgba(224, 57, 90, 0.12);
    color: #f07090;
}

body.theme-dark .post-action-btn[data-repost-button].is-active,
body.theme-dark .post-action-btn[data-repost-button]:hover {
    background: rgba(26, 171, 138, 0.12);
    color: #4ecfb0;
}

body.theme-dark .contact-item:hover {
    background: rgba(28, 55, 78, 0.55);
    border-color: rgba(90, 140, 180, 0.3);
}

body.theme-dark .contact-item.active {
    background: linear-gradient(135deg, rgba(120, 55, 30, 0.6), rgba(100, 42, 20, 0.5));
    border-color: rgba(200, 120, 80, 0.4);
}

body.theme-dark .attachment-link {
    color: #8bc8fb;
}

body.theme-dark .reaction-chip {
    background: rgba(23, 47, 67, 0.9);
    border-color: rgba(118, 157, 191, 0.34);
    color: #dcecff;
}

body.theme-dark .reaction-chip.active {
    background: rgba(106, 58, 41, 0.58);
    border-color: rgba(255, 154, 116, 0.48);
    color: #ffd3c3;
}

body.theme-dark .quick-react-btn,
body.theme-dark .emoji-insert-btn,
body.theme-dark .mini-btn,
body.theme-dark .bot-prompt-btn {
    background: rgba(26, 51, 73, 0.9);
    color: #e8f3ff;
    border-color: rgba(124, 162, 196, 0.32);
}

body.theme-dark .emoji-picker,
body.theme-dark .theme-choice-fieldset,
body.theme-dark .bot-helper-card {
    background: rgba(15, 32, 48, 0.92);
    border-color: rgba(118, 157, 191, 0.34);
}

body.theme-dark .switch-row,
body.theme-dark .theme-choice-option span {
    background: rgba(20, 41, 60, 0.9);
    border-color: rgba(116, 155, 190, 0.34);
    color: #e8f3ff;
}

body.theme-dark .theme-choice-option input[type="radio"]:checked + span {
    background: rgba(107, 56, 39, 0.55);
    border-color: rgba(255, 154, 115, 0.5);
    color: #ffdacc;
}

body.theme-dark .theme-choice-option span::before {
    border-color: #88aecd;
}

body.theme-dark .theme-choice-option input[type="radio"]:checked + span::before {
    border-color: #ffa17a;
    background: #ff8a5f;
}

body.theme-dark .settings-form .lang-switcher-select {
    background: linear-gradient(180deg, #162e45, #12273b);
    border-color: #3c607f;
    color: #e8f3ff;
}

body.theme-dark .settings-form .lang-switcher-select option {
    color: #102639;
}

body.theme-dark .switch-row input[type="checkbox"] {
    border-color: #5f819e;
    background: #2a4862;
}

body.theme-dark .switch-row input[type="checkbox"]::after {
    background: #eef7ff;
}

body.theme-dark .switch-row input[type="checkbox"]:checked {
    border-color: #ff9d73;
    background: linear-gradient(130deg, #ff8e62, #ff6a45);
}

body.theme-dark .story-ring.is-seen,
body.theme-dark .ig-avatar-shell,
body.theme-dark .ig-avatar-shell.is-seen,
body.theme-dark .ig-highlight-ring,
body.theme-dark .ig-highlight-ring-add {
    background: #2a455e;
}
/* Light theme: remove the grey halo for profiles without a story by softening the shell background */
.ig-avatar-shell:not(.has-story):not(.is-seen) {
    background: transparent;
    padding: 0;
}

body.theme-dark .story-avatar-fallback,
body.theme-dark .ig-avatar,
body.theme-dark .ig-highlight-core,
body.theme-dark .ig-highlight-core-add {
    border-color: #102131;
    background: #16334b;
    color: #e8f3ff;
}

body.theme-dark .story-plus-badge {
    border-color: #102131;
}

body.theme-dark .ig-tab {
    color: #9fbad4;
}

body.theme-dark .ig-tab.active {
    color: #f3f8ff;
    border-top-color: #f3f8ff;
}

body.theme-dark .ig-stat-link:hover {
    background: rgba(40, 72, 102, 0.44);
}

body.theme-dark .ig-stat-link.active {
    background: rgba(55, 96, 132, 0.54);
    color: #e6f2ff;
}

body.theme-dark .profile-connections-wrap {
    background: rgba(17, 37, 55, 0.82);
    border-color: rgba(119, 157, 190, 0.36);
}

body.theme-dark .ig-post-tile,
body.theme-dark .ig-private-state,
body.theme-dark .ig-post-fallback {
    background: #16344c;
    color: #d2e7fb;
}

body.theme-dark .ig-private-pill,
body.theme-dark .search-private-pill,
body.theme-dark .ig-role-line,
body.theme-dark .plan-chip,
body.theme-dark .student-progress-meta span {
    background: rgba(28, 53, 76, 0.92);
    border-color: rgba(118, 157, 190, 0.34);
    color: #d7e9fb;
}

body.theme-dark .story-time,
body.theme-dark .story-archive-time,
body.theme-dark .contact-meta p,
body.theme-dark .shared-post-head small {
    color: #a8c0d8;
}

body.theme-dark .story-label {
    color: #eaf6ff;
}

@media (max-width: 640px) {
    .theme-choice-fieldset {
        grid-template-columns: minmax(0, 1fr);
    }

    .settings-account-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .settings-account-switch-form,
    .settings-account-item .plan-chip {
        align-self: stretch;
    }
}












/* Auth pages keep their classic look regardless of selected theme */
body.auth-body {
    background: linear-gradient(160deg, #08131f 0%, #0e2740 42%, #17324a 100%);
}

body.auth-body .topbar {
    background: rgba(7, 19, 31, 0.8);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

body.auth-body .brand-text,
body.auth-body .top-nav > a,
body.auth-body .top-nav button {
    color: #e8f1ff;
}

body.auth-body .top-nav > a:hover,
body.auth-body .top-nav button:hover {
    background: rgba(255, 255, 255, 0.12);
}

body.auth-body .top-nav > a.pill-btn {
    color: #e8f1ff;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

body.auth-body .top-nav > a.pill-btn:hover {
    background: rgba(255, 255, 255, 0.16);
}

body.auth-body .auth-card {
    background: linear-gradient(165deg, rgba(10, 28, 45, 0.9), rgba(14, 39, 61, 0.86));
    border: 1px solid rgba(140, 184, 218, 0.34);
    box-shadow: 0 28px 52px rgba(5, 15, 25, 0.45);
    backdrop-filter: blur(8px);
}

body.auth-body .auth-card h2,
body.auth-body .auth-card-subtitle,
body.auth-body label {
    color: #e8f3ff;
}

body.auth-body .auth-card-subtitle {
    color: rgba(204, 223, 241, 0.86);
}

body.auth-body input,
body.auth-body textarea,
body.auth-body select {
    background: rgba(7, 20, 33, 0.62);
    color: #ecf6ff;
    border-color: rgba(138, 181, 216, 0.35);
}

body.auth-body input::placeholder,
body.auth-body textarea::placeholder {
    color: rgba(181, 204, 226, 0.8);
}

body.auth-body input:focus,
body.auth-body textarea:focus,
body.auth-body select:focus {
    border-color: #78add8;
    box-shadow: 0 0 0 4px rgba(120, 173, 216, 0.22);
}

body.auth-body .switch-text {
    color: rgba(198, 219, 238, 0.88);
}

body.auth-body .switch-text a {
    color: #a9d8ff;
}

body.auth-body .auth-password-toggle {
    border-color: rgba(139, 184, 219, 0.42);
    background: rgba(9, 25, 39, 0.68);
    color: #e9f4ff;
}

body.auth-body .auth-password-toggle:hover {
    background: rgba(15, 35, 53, 0.82);
}

/* Mobile-first navigation and layout refinements */
.mobile-tabbar {
    display: none;
}

@media (max-width: 900px) {
    body.is-authenticated .topbar-inner {
        padding: 10px 12px;
    }

    body.is-authenticated .brand-mark {
        width: 32px;
        height: 32px;
        border-radius: 10px;
    }

    body.is-authenticated .brand-text {
        font-size: 1rem;
    }

    body.is-authenticated .top-nav {
        display: none;
    }

    body.is-authenticated .page-shell {
        margin: 10px auto 12px;
        padding: 0 10px calc(94px + env(safe-area-inset-bottom));
    }

    body.is-authenticated .footer {
        display: none;
    }

    .mobile-tabbar {
        position: fixed;
        left: 10px;
        right: 10px;
        bottom: calc(10px + env(safe-area-inset-bottom));
        z-index: 95;
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 6px;
        border-radius: 18px;
        padding: 8px;
        border: 1px solid rgba(191, 214, 233, 0.75);
        background: rgba(250, 253, 255, 0.93);
        backdrop-filter: blur(12px);
        box-shadow: 0 18px 34px rgba(12, 36, 60, 0.18);
    }

    .mobile-tab {
        position: relative;
        min-height: 52px;
        border-radius: 14px;
        display: inline-flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        color: var(--text-muted);
        font-size: 0.64rem;
        font-weight: 700;
        letter-spacing: 0.2px;
        transition: background 160ms ease, color 160ms ease, transform 160ms ease;
    }

    .mobile-tab:active {
        transform: scale(0.98);
    }

    .mobile-tab.active {
        color: #1d4465;
        background: rgba(255, 106, 69, 0.16);
    }

    .mobile-tab-icon,
    .mobile-tab-avatar,
    .mobile-tab-avatar-fallback {
        width: 28px;
        height: 28px;
        border-radius: 999px;
        border: 1px solid #c9dced;
        background: #edf4fb;
        color: #1f4d76;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        object-fit: cover;
        font-size: 0.85rem;
        line-height: 1;
        font-weight: 800;
    }

    .mobile-tab-icon-brand {
        border: none;
        color: #ffffff;
        background: transparent;
        overflow: hidden;
        padding: 0;
        width: auto !important; /* Allow the image aspect ratio to breathe */
    }

    .mobile-tab-icon-publish {
        width: 32px;
        height: 32px;
        border: none;
        color: #ffffff;
        background: linear-gradient(135deg, #ff7e50, #ff5f3c);
        box-shadow: 0 10px 18px rgba(255, 106, 69, 0.34);
        font-size: 1rem;
    }

    .mobile-tab-publish.active {
        background: rgba(255, 106, 69, 0.2);
    }

    .mobile-tab-badge {
        position: absolute;
        top: 3px;
        right: 14px;
        min-width: 18px;
        height: 18px;
        padding: 0 5px;
        border-radius: 999px;
        background: #ef2b2b;
        color: #ffffff;
        font-size: 0.62rem;
        font-weight: 800;
        line-height: 18px;
        text-align: center;
        border: 2px solid rgba(255, 255, 255, 0.95);
    }

    .mobile-tab-label {
        line-height: 1;
    }

    .layout-grid > .feed-column {
        order: 1;
    }

    .layout-grid > .left-rail {
        order: 2;
        padding: 14px;
    }

    .layout-grid > .right-rail {
        order: 3;
        padding: 14px;
    }

    .stories-bar-card {
        padding: 12px 10px;
    }

    .stories-scroll {
        gap: 10px;
    }

    .story-slot {
        min-width: 76px;
        max-width: 76px;
    }

    .story-avatar-wrap,
    .story-ring {
        width: 66px;
        height: 66px;
    }

    .story-plus-badge {
        width: 22px;
        height: 22px;
    }

    body.messages-page.is-authenticated .page-shell {
        padding-bottom: calc(102px + env(safe-area-inset-bottom));
    }

    body.messages-page.is-authenticated .chat-layout {
        gap: 10px;
    }

    body.messages-page.is-authenticated .chat-sidebar {
        max-height: 34vh;
        overflow-y: auto;
    }

    body.messages-page.is-authenticated .chat-main {
        min-height: 58vh;
        display: grid;
        grid-template-rows: auto minmax(0, 1fr) auto;
    }

    body.messages-page.is-authenticated .messages-list {
        padding-bottom: 18px;
    }

    body.messages-page.is-authenticated .chat-form {
        position: sticky;
        bottom: calc(78px + env(safe-area-inset-bottom));
        margin-top: 8px;
    }

    body.theme-dark .mobile-tabbar {
        border-color: rgba(95, 132, 164, 0.45);
        background: rgba(10, 24, 38, 0.94);
        box-shadow: 0 20px 36px rgba(0, 0, 0, 0.45);
    }

    body.theme-dark .mobile-tab {
        color: #9eb8d1;
    }

    body.theme-dark .mobile-tab.active {
        color: #f4f9ff;
        background: rgba(255, 106, 69, 0.22);
    }

    body.theme-dark .mobile-tab-icon,
    body.theme-dark .mobile-tab-avatar,
    body.theme-dark .mobile-tab-avatar-fallback {
        border-color: #4a6f90;
        background: #17334b;
        color: #e8f3ff;
    }

    body.theme-dark .mobile-tab-badge {
        border-color: #102131;
    }
}

@media (max-width: 520px) {
    .mobile-tab-label {
        display: none;
    }

    .mobile-tab {
        min-height: 46px;
        gap: 0;
    }

    .mobile-tab-badge {
        right: 7px;
    }
}

/* Mobile compact profile layout (Instagram/TikTok-like density) */
@media (max-width: 900px) {
    body.profile-page.is-authenticated .profile-ig-wrap {
        padding: 14px 10px;
        border-radius: 18px;
    }

    body.profile-page.is-authenticated .ig-profile-header {
        grid-template-columns: 90px minmax(0, 1fr);
        gap: 10px;
        align-items: start;
        padding-bottom: 14px;
    }

    body.profile-page.is-authenticated .ig-avatar-col {
        place-items: start center;
    }

    body.profile-page.is-authenticated .ig-avatar-wrap,
    body.profile-page.is-authenticated .ig-avatar-shell {
        width: 88px;
        height: 88px;
    }

    body.profile-page.is-authenticated .ig-avatar {
        width: 80px;
        height: 80px;
        border-width: 2px;
        font-size: 1.2rem;
    }

    body.profile-page.is-authenticated .ig-avatar-wrap .story-plus-badge {
        width: 20px;
        height: 20px;
        right: -1px;
        bottom: -1px;
        border-width: 1.5px;
        font-size: 0.75rem;
    }

    body.profile-page.is-authenticated .ig-meta-col {
        gap: 8px;
    }

    body.profile-page.is-authenticated .ig-bio-block {
        gap: 2px;
    }

    body.profile-page.is-authenticated .ig-bio-text {
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        overflow: hidden;
    }

    body.profile-page.is-authenticated .ig-top-row {
        gap: 6px;
    }

    body.profile-page.is-authenticated .ig-username {
        font-size: 1.05rem;
        margin-right: 0;
    }

    body.profile-page.is-authenticated .ig-top-row .mini-btn,
    body.profile-page.is-authenticated .ig-top-row .primary-btn {
        padding: 6px 9px;
        font-size: 0.72rem;
        border-radius: 10px;
    }

    body.profile-page.is-authenticated .ig-follow-btn {
        padding: 6px 10px;
    }

    body.profile-page.is-authenticated .ig-private-pill {
        padding: 2px 8px;
        font-size: 0.62rem;
    }

    body.profile-page.is-authenticated .ig-stat-line {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
        font-size: 0.72rem;
        text-align: center;
    }

    body.profile-page.is-authenticated .ig-stat-line span,
    body.profile-page.is-authenticated .ig-stat-line .ig-stat-link {
        display: grid;
        gap: 2px;
    }

    body.profile-page.is-authenticated .ig-stat-line .ig-stat-link {
        margin: 0;
        padding: 2px 4px;
    }

    body.profile-page.is-authenticated .ig-stat-line strong {
        font-size: 0.9rem;
        line-height: 1;
    }

    body.profile-page.is-authenticated .ig-bio-block strong {
        font-size: 0.82rem;
    }

    body.profile-page.is-authenticated .ig-role-line {
        font-size: 0.68rem;
        padding: 3px 8px;
    }

    body.profile-page.is-authenticated .ig-country-line,
    body.profile-page.is-authenticated .ig-email-line,
    body.profile-page.is-authenticated .ig-bio-text {
        font-size: 0.78rem;
        line-height: 1.35;
    }

    body.profile-page.is-authenticated .profile-plan-chips {
        gap: 6px;
        margin-top: 4px;
    }

    body.profile-page.is-authenticated .plan-chip {
        font-size: 0.66rem;
        padding: 4px 8px;
    }

    body.profile-page.is-authenticated .ig-highlights {
        gap: 12px;
        padding: 10px 2px 14px;
    }

    body.profile-page.is-authenticated .ig-highlight-item {
        min-width: 56px;
        gap: 6px;
    }

    body.profile-page.is-authenticated .ig-highlight-ring {
        width: 56px;
        height: 56px;
    }

    body.profile-page.is-authenticated .ig-highlight-item small {
        font-size: 0.64rem;
        max-width: 56px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    body.profile-page.is-authenticated .ig-highlight-core-add {
        font-size: 1.3rem;
    }

    body.profile-page.is-authenticated .ig-tabs {
        gap: 12px;
    }

    body.profile-page.is-authenticated .ig-tab {
        padding: 10px 0;
        font-size: 0.62rem;
        letter-spacing: 0.5px;
    }

    body.profile-page.is-authenticated .ig-private-state {
        margin-top: 12px;
        padding: 14px;
        border-radius: 12px;
    }
}

@media (max-width: 520px) {
    body.profile-page.is-authenticated .ig-profile-header {
        grid-template-columns: 80px minmax(0, 1fr);
        gap: 8px;
    }

    body.profile-page.is-authenticated .ig-avatar-wrap,
    body.profile-page.is-authenticated .ig-avatar-shell {
        width: 76px;
        height: 76px;
    }

    body.profile-page.is-authenticated .ig-avatar {
        width: 69px;
        height: 69px;
        font-size: 1rem;
    }

    body.profile-page.is-authenticated .ig-username {
        font-size: 0.96rem;
    }

    body.profile-page.is-authenticated .ig-top-row .mini-btn,
    body.profile-page.is-authenticated .ig-top-row .primary-btn {
        padding: 5px 8px;
        font-size: 0.68rem;
    }

    body.profile-page.is-authenticated .ig-stat-line {
        font-size: 0.68rem;
        gap: 6px;
    }

    body.profile-page.is-authenticated .ig-stat-line strong {
        font-size: 0.82rem;
    }
}

/* Extra compact profile header on mobile */
@media (max-width: 900px) {
    body.profile-page.is-authenticated .ig-stat-line {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    body.profile-page.is-authenticated .ig-bio-block {
        gap: 2px;
    }

    body.profile-page.is-authenticated .ig-bio-block > strong {
        display: none;
    }

    body.profile-page.is-authenticated .ig-bio-text {
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        overflow: hidden;
    }
}

/* Mobile student progress: no subject frames, only clean gauges */
@media (max-width: 900px) {
    body.profile-page.is-authenticated .student-progress-card {
        border: none;
        background: transparent;
        box-shadow: none;
        padding: 4px 0 0;
        margin-top: 6px;
        max-height: 160px;
        overflow-y: auto;
    }

    body.profile-page.is-authenticated .student-progress-title {
        font-size: 0.78rem;
        margin-bottom: 2px;
    }

    body.profile-page.is-authenticated .student-progress-meta {
        gap: 6px;
        font-size: 0.7rem;
        color: #3f6788;
    }

    body.profile-page.is-authenticated .student-progress-meta span {
        border: none;
        background: transparent;
        padding: 0;
        border-radius: 0;
        font-weight: 700;
    }

    body.profile-page.is-authenticated .student-progress-row {
        gap: 4px;
    }

    body.profile-page.is-authenticated .student-progress-head {
        font-size: 0.78rem;
    }

    body.profile-page.is-authenticated .student-progress-track {
        height: 14px;
    }
}
/* Final mobile fit pass: compact profile, horizontal gauges, left-aligned bio */
@media (max-width: 900px) {
    body.profile-page.is-authenticated .ig-profile-header {
        gap: 8px;
        padding-bottom: 8px;
    }

    body.profile-page.is-authenticated .ig-meta-col {
        gap: 5px;
    }

    body.profile-page.is-authenticated .ig-bio-block {
        gap: 1px;
        justify-items: start;
    }

    body.profile-page.is-authenticated .ig-role-line,
    body.profile-page.is-authenticated .ig-country-line,
    body.profile-page.is-authenticated .ig-email-line,
    body.profile-page.is-authenticated .ig-bio-text {
        text-align: start;
        justify-self: start;
    }

    body.profile-page.is-authenticated .ig-country-line,
    body.profile-page.is-authenticated .ig-email-line {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    body.profile-page.is-authenticated .ig-bio-text {
        width: 100%;
        -webkit-line-clamp: 1;
    }

    body.profile-page.is-authenticated .profile-plan-chips {
        margin-top: 2px;
        gap: 4px;
    }

    body.profile-page.is-authenticated .plan-chip {
        padding: 2px 6px;
        font-size: 0.62rem;
    }

    body.profile-page.is-authenticated .student-progress-card {
        border: none;
        background: transparent;
        box-shadow: none;
        padding: 0;
        margin-top: 2px;
        max-height: none;
        overflow: visible;
        gap: 3px;
    }

    body.profile-page.is-authenticated .student-progress-title,
    body.profile-page.is-authenticated .student-progress-meta {
        display: none;
    }

    body.profile-page.is-authenticated .student-progress-row {
        display: grid;
        grid-template-columns: minmax(56px, 32%) minmax(0, 1fr) 36px;
        align-items: center;
        gap: 6px;
    }

    body.profile-page.is-authenticated .student-progress-head {
        display: contents;
    }

    body.profile-page.is-authenticated .student-progress-head span {
        grid-column: 1;
        font-size: 0.7rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    body.profile-page.is-authenticated .student-progress-head strong {
        grid-column: 3;
        text-align: right;
        font-size: 0.68rem;
        line-height: 1;
    }

    body.profile-page.is-authenticated .student-progress-track {
        grid-column: 2;
        height: 10px;
    }

    body.profile-page.is-authenticated .ig-highlights {
        gap: 8px;
        padding: 6px 2px 8px;
    }

    body.profile-page.is-authenticated .ig-highlight-item {
        min-width: 48px;
        gap: 4px;
    }

    body.profile-page.is-authenticated .ig-highlight-ring {
        width: 48px;
        height: 48px;
    }

    body.profile-page.is-authenticated .ig-highlight-item small {
        max-width: 48px;
        font-size: 0.58rem;
    }

    body.profile-page.is-authenticated .ig-tabs {
        margin-top: 2px;
    }
}

@media (max-width: 520px) {
    body.profile-page.is-authenticated .student-progress-row {
        grid-template-columns: minmax(48px, 34%) minmax(0, 1fr) 32px;
        gap: 5px;
    }

    body.profile-page.is-authenticated .student-progress-head span {
        font-size: 0.66rem;
    }

    body.profile-page.is-authenticated .student-progress-head strong {
        font-size: 0.64rem;
    }

    body.profile-page.is-authenticated .student-progress-track {
        height: 9px;
    }
}
/* Mobile profile: settings shortcut + thin multicolor subject gauges */
.ig-mobile-settings {
    display: none;
}

@media (max-width: 900px) {
    body.profile-page.is-authenticated .ig-meta-col {
        position: relative;
    }

    body.profile-page.is-authenticated .ig-mobile-settings {
        display: inline-flex;
        position: absolute;
        top: 0;
        right: 0;
        width: 28px;
        height: 28px;
        border-radius: 999px;
        align-items: center;
        justify-content: center;
        border: 1px solid #c8dced;
        background: #edf4fb;
        color: #1f4d76;
        font-size: 0.85rem;
        line-height: 1;
        z-index: 2;
    }

    body.profile-page.is-authenticated .ig-top-row {
        padding-right: 34px;
    }

    body.profile-page.is-authenticated .student-progress-track {
        height: 6px;
        background: #dfe9f3;
    }

    body.profile-page.is-authenticated .student-progress-track span {
        background: linear-gradient(90deg, #4f9cff 0%, #36d6bb 45%, #f7c84c 100%);
    }

    body.profile-page.is-authenticated .student-color-1 .student-progress-track span {
        background: linear-gradient(90deg, #3f8cff 0%, #3fd1ff 48%, #4ce59f 100%);
    }

    body.profile-page.is-authenticated .student-color-2 .student-progress-track span {
        background: linear-gradient(90deg, #ff7d66 0%, #ffb347 52%, #ffd66f 100%);
    }

    body.profile-page.is-authenticated .student-color-3 .student-progress-track span {
        background: linear-gradient(90deg, #9b6bff 0%, #4f8dff 50%, #44d7e6 100%);
    }

    body.theme-dark.profile-page.is-authenticated .ig-mobile-settings {
        border-color: #4a6f90;
        background: #17334b;
        color: #e8f3ff;
    }

    body.theme-dark.profile-page.is-authenticated .student-progress-track {
        background: #233e56;
    }
}

@media (max-width: 520px) {
    body.profile-page.is-authenticated .ig-mobile-settings {
        width: 26px;
        height: 26px;
        font-size: 0.8rem;
    }

    body.profile-page.is-authenticated .ig-top-row {
        padding-right: 32px;
    }

    body.profile-page.is-authenticated .student-progress-track {
        height: 5px;
    }
}
/* Settings mobile back button */
.settings-back-link {
    display: none;
}

@media (max-width: 960px) {
    .settings-back-link {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        margin: 2px 0 10px;
        padding: 6px 10px;
        border-radius: 999px;
        border: 1px solid #cfe0ef;
        background: #f3f9ff;
        color: #214969;
        font-size: 0.82rem;
        font-weight: 800;
        width: fit-content;
    }

    body.theme-dark .settings-back-link {
        border-color: #4a6f90;
        background: #16324a;
        color: #e8f3ff;
    }
}

/* Ensure mobile student gauges are clearly visible */
@media (max-width: 900px) {
    body.profile-page.is-authenticated .student-progress-row {
        grid-template-columns: minmax(42px, 24%) minmax(0, 1fr) 30px;
        gap: 6px;
    }

    body.profile-page.is-authenticated .student-progress-track {
        grid-column: 2;
        display: block;
        width: 100%;
        height: 8px;
        border-radius: 999px;
        border: 1px solid #c9dbea;
        background: #e7eff7;
        overflow: hidden;
    }

    body.profile-page.is-authenticated .student-progress-track span {
        display: block;
        height: 100%;
        min-width: 4px;
        border-radius: 999px;
        opacity: 1;
        filter: saturate(1.05);
    }

    body.theme-dark.profile-page.is-authenticated .student-progress-track {
        border-color: #3f607d;
        background: #233e56;
    }
}

@media (max-width: 520px) {
    body.profile-page.is-authenticated .student-progress-row {
        grid-template-columns: minmax(38px, 26%) minmax(0, 1fr) 28px;
        gap: 5px;
    }

    body.profile-page.is-authenticated .student-progress-track {
        height: 7px;
    }
}
/* Settings single-section mode + final profile gauge width tuning */
.settings-menu-nav a.is-active {
    background: #ffece2;
    border-color: #ffcbb8;
    color: #8f3f27;
}

body.theme-dark .settings-menu-nav a.is-active {
    background: rgba(107, 56, 39, 0.52);
    border-color: rgba(255, 153, 115, 0.58);
    color: #ffd9ca;
}

body.profile-page .ig-bio-block,
body.profile-page .ig-bio-block p,
body.profile-page .ig-bio-block strong {
    text-align: left;
}

body.profile-page .ig-bio-block {
    justify-items: start;
}

@media (max-width: 900px) {
    body.profile-page.is-authenticated .student-progress-card {
        max-height: none;
        overflow: visible;
    }

    body.profile-page.is-authenticated .student-progress-row {
        display: grid;
        grid-template-columns: minmax(34px, 16%) minmax(0, 1fr);
        gap: 6px;
        align-items: center;
    }

    body.profile-page.is-authenticated .student-progress-head {
        display: block;
        grid-column: 1;
        min-width: 0;
    }

    body.profile-page.is-authenticated .student-progress-head span {
        display: block;
        font-size: 0.62rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    body.profile-page.is-authenticated .student-progress-head strong {
        display: none;
    }

    body.profile-page.is-authenticated .student-progress-track {
        grid-column: 2;
        width: 100%;
        height: 8px;
        border-radius: 999px;
        border: 1px solid #c9dbea;
        background: #e7eff7;
    }

    body.profile-page.is-authenticated .student-progress-track span {
        min-width: 12px;
    }

    body.theme-dark.profile-page.is-authenticated .student-progress-track {
        border-color: #3f607d;
        background: #233e56;
    }
}

@media (max-width: 520px) {
    body.profile-page.is-authenticated .student-progress-row {
        grid-template-columns: minmax(30px, 15%) minmax(0, 1fr);
        gap: 5px;
    }

    body.profile-page.is-authenticated .student-progress-track {
        height: 7px;
    }
}
.settings-section-card[hidden] {
    display: none !important;
}

/* Mobile settings flow: menu and section are separate screens */
@media (max-width: 960px) {
    .settings-modern-shell.is-section-view {
        grid-template-columns: minmax(0, 1fr);
    }

    .settings-modern-shell.is-section-view .settings-menu-card {
        display: none;
    }

    .settings-modern-shell:not(.is-section-view) .settings-modern-content {
        display: none;
    }

    .settings-modern-shell.is-section-view .settings-modern-content {
        display: grid;
    }

    .settings-back-link.settings-back-menu {
        position: sticky;
        top: calc(72px + env(safe-area-inset-top));
        left: 0;
        z-index: 70;
    }
}

/* Final mobile gauge width boost */
@media (max-width: 900px) {
    body.profile-page.is-authenticated .student-progress-card {
        width: 100%;
        max-width: 100%;
        padding: 0;
        margin-top: 2px;
    }

    body.profile-page.is-authenticated .student-progress-row {
        width: 100%;
        display: grid;
        grid-template-columns: minmax(24px, 8%) minmax(0, 1fr) !important;
        column-gap: 8px !important;
        align-items: center;
    }

    body.profile-page.is-authenticated .student-progress-head {
        grid-column: 1;
        max-width: 24px;
        min-width: 0;
    }

    body.profile-page.is-authenticated .student-progress-head span {
        font-size: 0.56rem;
        line-height: 1;
        letter-spacing: 0.1px;
    }

    body.profile-page.is-authenticated .student-progress-track {
        grid-column: 2;
        width: 100% !important;
        min-width: 0;
        height: 9px !important;
        border-radius: 999px;
    }

    body.profile-page.is-authenticated .student-progress-track span {
        min-width: 16px;
    }
}

@media (max-width: 520px) {
    body.profile-page.is-authenticated .student-progress-row {
        grid-template-columns: minmax(20px, 7%) minmax(0, 1fr) !important;
        column-gap: 7px !important;
    }

    body.profile-page.is-authenticated .student-progress-head {
        max-width: 20px;
    }

    body.profile-page.is-authenticated .student-progress-track {
        height: 8px !important;
    }
}

/* Code-based icon system (SVG) for nav and mobile UI */
.ui-icon {
    display: block;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.top-nav-icon .ui-icon {
    width: 15px;
    height: 15px;
}

.ui-icon-settings {
    stroke-width: 1.65;
}

.profile-icon-glyph {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.profile-icon-glyph .ui-icon {
    width: 18px;
    height: 18px;
}

.ig-mobile-settings .ui-icon {
    width: 16px;
    height: 16px;
}

@media (max-width: 900px) {
    .mobile-tab-icon .ui-icon {
        width: 16px;
        height: 16px;
    }

    .mobile-tab-icon-publish .ui-icon {
        width: 18px;
        height: 18px;
        stroke-width: 2.2;
    }
}

/* Profile grid overlay stats: icon SVG instead of emoji glyphs */
.ig-post-stat {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.ig-post-stat svg {
    width: 14px;
    height: 14px;
    display: block;
}

/* Feed mobile top-right actions (notifications + messages) */
.mobile-feed-actions {
    display: none;
}

@media (max-width: 900px) {
    body.is-authenticated .mobile-feed-actions {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        margin-left: auto;
    }

    body.is-authenticated .mobile-feed-action {
        position: relative;
        width: 32px;
        height: 32px;
        border-radius: 999px;
        border: 1px solid #c9dced;
        background: #edf4fb;
        color: #1f4d76;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    body.is-authenticated .mobile-feed-action .ui-icon {
        width: 16px;
        height: 16px;
    }

    body.is-authenticated .mobile-feed-action-badge {
        position: absolute;
        top: -4px;
        right: -4px;
        min-width: 17px;
        height: 17px;
        padding: 0 4px;
        border-radius: 999px;
        background: #ef2b2b;
        color: #ffffff;
        font-size: 0.58rem;
        font-weight: 800;
        line-height: 17px;
        text-align: center;
        border: 2px solid rgba(255, 255, 255, 0.95);
    }

    body.theme-dark .mobile-feed-action {
        border-color: #4a6f90;
        background: #17334b;
        color: #e8f3ff;
    }

    body.theme-dark .mobile-feed-action-badge {
        border-color: #102131;
    }
}

@media (max-width: 520px) {
    body.is-authenticated .mobile-feed-action {
        width: 30px;
        height: 30px;
    }

    body.is-authenticated .mobile-feed-action .ui-icon {
        width: 15px;
        height: 15px;
    }
}

/* Mobile messaging redesign: one-pane conversations (Instagram/TikTok style) */
.chat-mobile-back {
    display: none;
}

@media (max-width: 900px) {
    body.messages-page.is-authenticated .chat-layout {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: 0;
        min-height: calc(100vh - 178px);
    }

    body.messages-page.is-authenticated .chat-sidebar,
    body.messages-page.is-authenticated .chat-main {
        border-radius: 18px;
        padding: 12px;
    }

    body.messages-page.is-authenticated .chat-layout.has-active-chat .chat-sidebar {
        display: none;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .chat-main {
        display: none;
    }

    body.messages-page.is-authenticated .chat-layout.has-active-chat .chat-main {
        display: grid;
        grid-template-rows: auto minmax(0, 1fr) auto;
        min-height: calc(100vh - 190px);
        gap: 8px;
    }

    body.messages-page.is-authenticated .chat-sidebar .section-head {
        position: sticky;
        top: 0;
        z-index: 3;
        background: inherit;
        padding-bottom: 8px;
    }

    body.messages-page.is-authenticated .chat-head-actions a[href*="dashboard"] {
        display: none;
    }

    body.messages-page.is-authenticated .contacts-list {
        margin-top: 8px;
        gap: 8px;
    }

    body.messages-page.is-authenticated .contact-item {
        grid-template-columns: minmax(0, 1fr) auto;
        padding: 12px 10px;
        border-radius: 16px;
    }

    body.messages-page.is-authenticated .contact-profile-link {
        display: none;
    }

    body.messages-page.is-authenticated .chat-header {
        position: sticky;
        top: 0;
        z-index: 4;
        background: inherit;
        border-bottom: 1px solid #dbe6f1;
        padding: 2px 0 10px;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
    }

    body.messages-page.is-authenticated .chat-mobile-back {
        display: inline-flex;
        width: 34px;
        height: 34px;
        border-radius: 999px;
        border: 1px solid #c9dced;
        background: #edf4fb;
        color: #1f4d76;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }

    body.messages-page.is-authenticated .chat-mobile-back .ui-icon {
        width: 16px;
        height: 16px;
    }

    body.messages-page.is-authenticated .chat-header-user {
        min-width: 0;
        flex: 1;
    }

    body.messages-page.is-authenticated .chat-header h2 {
        font-size: 0.97rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    body.messages-page.is-authenticated .chat-header form {
        display: none;
    }

    body.messages-page.is-authenticated .messages-list {
        min-height: 0;
        max-height: none;
        padding: 0 2px 14px;
        gap: 10px;
    }

    body.messages-page.is-authenticated .bubble {
        max-width: 88%;
        border-radius: 16px;
    }

    body.messages-page.is-authenticated .chat-form {
        position: sticky;
        bottom: calc(78px + env(safe-area-inset-bottom));
        margin-top: 0;
        padding-top: 8px;
        background: inherit;
        border-top: 1px solid #dbe6f1;
        z-index: 4;
    }

    body.messages-page.is-authenticated .chat-composer-row {
        justify-content: space-between;
    }

    body.messages-page.is-authenticated #message-text {
        min-height: 42px;
        max-height: 120px;
    }

    body.theme-dark.messages-page.is-authenticated .chat-mobile-back {
        border-color: #4a6f90;
        background: #17334b;
        color: #e8f3ff;
    }

    body.theme-dark.messages-page.is-authenticated .chat-header,
    body.theme-dark.messages-page.is-authenticated .chat-form {
        border-color: rgba(123, 161, 194, 0.32);
    }
}

@media (min-width: 901px) {
    .chat-mobile-back {
        display: none !important;
    }
}

/* Mobile messaging final pass: full-height list + full-height conversation */
@media (max-width: 900px) {
    body.messages-page.is-authenticated .page-shell {
        margin-top: 8px;
        padding-bottom: calc(102px + env(safe-area-inset-bottom));
    }

    body.messages-page.is-authenticated .chat-layout {
        height: calc(100dvh - 154px);
        min-height: calc(100dvh - 154px);
        max-height: calc(100dvh - 154px);
        overflow: hidden;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .chat-sidebar {
        display: grid;
        grid-template-rows: auto minmax(0, 1fr);
        height: 100%;
        max-height: none;
        overflow: hidden;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contacts-list {
        min-height: 0;
        overflow-y: auto;
        padding-bottom: 6px;
    }

    body.messages-page.is-authenticated .chat-layout.has-active-chat .chat-main {
        display: flex;
        flex-direction: column;
        height: 100%;
        min-height: 0;
        max-height: none;
    }

    body.messages-page.is-authenticated .chat-layout.has-active-chat .messages-list {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 8px;
    }

    body.messages-page.is-authenticated .chat-layout.has-active-chat .chat-form {
        margin-top: 0;
        flex-shrink: 0;
        bottom: calc(78px + env(safe-area-inset-bottom));
    }

    body.messages-page.is-authenticated .chat-layout.has-active-chat .chat-header {
        flex-shrink: 0;
    }
}

/* Contact list metadata polish */
.contact-meta-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.contact-time {
    color: var(--text-muted);
    font-size: 0.72rem;
    white-space: nowrap;
}

@media (max-width: 900px) {
    body.messages-page.is-authenticated .contact-time {
        font-size: 0.68rem;
    }
}

/* Conversation tap reliability on mobile */
.contact-row-form {
    margin: 0;
    width: 100%;
}

.contact-item {
    cursor: pointer;
}

.contact-row-link {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    width: 100%;
    color: inherit;
    text-decoration: none;
    font: inherit;
    text-align: left;
    appearance: none;
    -webkit-appearance: none;
    touch-action: manipulation;
}

.contact-row-link .contact-meta {
    min-width: 0;
}

body.messages-page .contacts-list {
    position: relative;
    z-index: 20;
}

@media (hover: none) {
    .contact-item:hover {
        transform: none;
        box-shadow: 0 18px 42px rgba(8, 29, 50, 0.18);
    }
}


/* Immersive chat design refresh (Instagram/TikTok spirit, Zerino colors) */
body.messages-page .chat-layout.has-active-chat .chat-main {
    position: relative;
    overflow: hidden;
    border-radius: 24px;
    border: 1px solid rgba(167, 196, 223, 0.52);
    background:
        radial-gradient(120% 90% at 10% -15%, rgba(255, 116, 84, 0.2), transparent 56%),
        radial-gradient(95% 80% at 100% 0%, rgba(28, 192, 146, 0.16), transparent 58%),
        linear-gradient(180deg, rgba(249, 253, 255, 0.97), rgba(237, 246, 255, 0.96));
    box-shadow: 0 24px 54px rgba(8, 31, 52, 0.24);
}

body.messages-page .chat-layout.has-active-chat .chat-main::before,
body.messages-page .chat-layout.has-active-chat .chat-main::after {
    content: "";
    position: absolute;
    border-radius: 999px;
    pointer-events: none;
}

body.messages-page .chat-layout.has-active-chat .chat-main::before {
    width: 280px;
    height: 280px;
    top: -120px;
    right: -72px;
    background: radial-gradient(circle at 30% 30%, rgba(255, 126, 73, 0.24), rgba(255, 126, 73, 0));
}

body.messages-page .chat-layout.has-active-chat .chat-main::after {
    width: 220px;
    height: 220px;
    bottom: -90px;
    left: -70px;
    background: radial-gradient(circle at 40% 35%, rgba(12, 181, 135, 0.2), rgba(12, 181, 135, 0));
}

body.messages-page .chat-layout.has-active-chat .chat-header,
body.messages-page .chat-layout.has-active-chat .messages-list,
body.messages-page .chat-layout.has-active-chat .chat-form,
body.messages-page .chat-layout.has-active-chat .bot-helper-card {
    position: relative;
    z-index: 1;
}

body.messages-page .chat-layout.has-active-chat .chat-header {
    margin: -4px -4px 0;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(173, 197, 219, 0.48);
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(247, 252, 255, 0.62));
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 22px rgba(12, 39, 62, 0.08);
}

body.messages-page .chat-layout.has-active-chat .chat-header-user {
    min-width: 0;
    flex: 1;
    gap: 10px;
    color: inherit;
}

body.messages-page .chat-layout.has-active-chat .chat-header-user .avatar {
    box-shadow: 0 7px 18px rgba(11, 36, 57, 0.2);
}

body.messages-page .chat-layout.has-active-chat .chat-header-meta {
    min-width: 0;
    display: grid;
    gap: 1px;
}

body.messages-page .chat-layout.has-active-chat .chat-header h2 {
    font-size: 1rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

body.messages-page .chat-layout.has-active-chat .chat-status {
    color: #4a637a;
    font-size: 0.76rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

body.messages-page .chat-layout.has-active-chat .messages-list {
    padding: 14px 8px 14px;
    gap: 12px;
    background:
        linear-gradient(180deg, rgba(253, 254, 255, 0.46), rgba(245, 250, 255, 0.22));
    border-radius: 16px;
    scrollbar-width: thin;
    scrollbar-color: rgba(86, 132, 172, 0.38) transparent;
}

body.messages-page .chat-layout.has-active-chat .messages-list::-webkit-scrollbar {
    width: 9px;
}

body.messages-page .chat-layout.has-active-chat .messages-list::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(96, 143, 184, 0.54), rgba(86, 128, 168, 0.2));
}

body.messages-page .chat-layout.has-active-chat .bubble {
    position: relative;
    border-radius: 18px;
    padding: 12px 13px;
    max-width: min(600px, 83%);
    border: 1px solid rgba(182, 204, 225, 0.58);
    box-shadow: 0 12px 26px rgba(11, 33, 53, 0.12);
    gap: 6px;
    animation: chatBubbleIn 220ms ease;
}

@keyframes chatBubbleIn {
    from {
        opacity: 0;
        transform: translateY(7px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

body.messages-page .chat-layout.has-active-chat .bubble::after {
    content: "";
    position: absolute;
    bottom: 11px;
    width: 11px;
    height: 11px;
    border-radius: 3px;
    transform: rotate(45deg);
}

body.messages-page .chat-layout.has-active-chat .bubble.theirs {
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.98), rgba(246, 251, 255, 0.96));
}

body.messages-page .chat-layout.has-active-chat .bubble.theirs::after {
    left: -4px;
    background: rgba(247, 252, 255, 0.98);
    border-left: 1px solid rgba(182, 204, 225, 0.58);
    border-bottom: 1px solid rgba(182, 204, 225, 0.58);
}

body.messages-page .chat-layout.has-active-chat .bubble.mine {
    border-color: rgba(255, 178, 149, 0.7);
    background: linear-gradient(140deg, #ffede5, #ffd9cb 58%, #ffd0bd);
    color: #622d1f;
    box-shadow: 0 14px 28px rgba(188, 85, 49, 0.22);
}

body.messages-page .chat-layout.has-active-chat .bubble.mine::after {
    right: -4px;
    background: #ffd7c7;
    border-right: 1px solid rgba(255, 178, 149, 0.72);
    border-bottom: 1px solid rgba(255, 178, 149, 0.72);
}

body.messages-page .chat-layout.has-active-chat .bubble-head {
    color: #35526d;
    font-size: 0.8rem;
}

body.messages-page .chat-layout.has-active-chat .bubble-head small {
    font-weight: 700;
    color: #63809b;
}

body.messages-page .chat-layout.has-active-chat .bubble p {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.44;
}

body.messages-page .chat-layout.has-active-chat .reaction-strip {
    margin-top: 7px;
}

body.messages-page .chat-layout.has-active-chat .reaction-chip {
    padding: 3px 8px;
    border-radius: 999px;
    border-color: rgba(172, 198, 221, 0.84);
    background: rgba(248, 252, 255, 0.92);
    box-shadow: 0 4px 10px rgba(20, 49, 74, 0.08);
}

body.messages-page .chat-layout.has-active-chat .quick-react-row {
    margin-top: 7px;
    opacity: 0.9;
}

body.messages-page .chat-layout.has-active-chat .quick-react-btn {
    background: rgba(236, 244, 252, 0.95);
    border: 1px solid rgba(184, 208, 230, 0.64);
    box-shadow: 0 4px 8px rgba(11, 35, 57, 0.08);
}

body.messages-page .chat-layout.has-active-chat .chat-form {
    margin: 0 -2px -2px;
    padding: 9px 10px 10px;
    border-radius: 18px;
    border: 1px solid rgba(167, 196, 223, 0.54);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(243, 249, 255, 0.84));
    backdrop-filter: blur(10px);
    box-shadow: 0 -10px 26px rgba(10, 35, 57, 0.09);
}

body.messages-page .chat-layout.has-active-chat #message-text {
    min-height: 44px;
    max-height: 140px;
    resize: none;
    border-radius: 14px;
    border: 1px solid rgba(171, 198, 221, 0.72);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

body.messages-page .chat-layout.has-active-chat #message-text:focus {
    border-color: #ff8f6a;
    box-shadow: 0 0 0 4px rgba(255, 127, 89, 0.16);
}

body.messages-page .chat-layout.has-active-chat .chat-composer-row {
    justify-content: space-between;
    gap: 10px;
}

body.messages-page .chat-layout.has-active-chat .chat-composer-row .icon-btn {
    width: 38px;
    height: 38px;
    border: 1px solid rgba(176, 202, 225, 0.66);
    background: rgba(245, 250, 255, 0.96);
    box-shadow: 0 5px 12px rgba(17, 44, 66, 0.12);
}

body.messages-page .chat-layout.has-active-chat .chat-composer-row .icon-btn:hover {
    transform: translateY(-1px);
}

body.messages-page .chat-layout.has-active-chat .chat-composer-row .icon-send {
    border: none;
    background: linear-gradient(140deg, #ff6d4a, #ff8d5a);
    box-shadow: 0 9px 18px rgba(197, 86, 52, 0.34);
}

body.messages-page .chat-layout.has-active-chat .emoji-picker {
    border-radius: 14px;
    border: 1px solid rgba(171, 198, 221, 0.72);
    background: rgba(249, 253, 255, 0.98);
    box-shadow: 0 10px 20px rgba(13, 35, 56, 0.1);
}

body.messages-page .chat-layout.has-active-chat .emoji-insert-btn {
    border: 1px solid rgba(174, 198, 220, 0.7);
    background: #ffffff;
}

body.messages-page .chat-layout.has-active-chat .bot-helper-card {
    border-radius: 15px;
    border: 1px solid rgba(173, 202, 225, 0.7);
    background: linear-gradient(135deg, rgba(247, 252, 255, 0.94), rgba(238, 248, 255, 0.92));
    box-shadow: 0 12px 24px rgba(11, 34, 54, 0.08);
}

body.messages-page .chat-layout.has-active-chat .shared-post-card {
    border-radius: 14px;
    border: 1px solid rgba(176, 201, 223, 0.74);
    background: rgba(248, 252, 255, 0.88);
    box-shadow: 0 8px 16px rgba(11, 35, 56, 0.1);
}

body.messages-page .chat-layout.has-active-chat .chat-mobile-back {
    border-color: rgba(174, 201, 224, 0.74);
    background: rgba(245, 251, 255, 0.96);
    box-shadow: 0 4px 11px rgba(15, 44, 67, 0.12);
}

@media (max-width: 900px) {
    body.messages-page .chat-layout.has-active-chat .chat-main {
        border-radius: 20px;
    }

    body.messages-page .chat-layout.has-active-chat .chat-header {
        margin: -2px -2px 0;
        padding: 9px 9px 10px;
        border-radius: 14px;
    }

    body.messages-page .chat-layout.has-active-chat .chat-header h2 {
        font-size: 0.94rem;
    }

    body.messages-page .chat-layout.has-active-chat .chat-status {
        font-size: 0.68rem;
    }

    body.messages-page .chat-layout.has-active-chat .messages-list {
        padding: 10px 4px 10px;
        gap: 10px;
    }

    body.messages-page .chat-layout.has-active-chat .bubble {
        max-width: 91%;
        border-radius: 16px;
        padding: 10px 11px;
    }

    body.messages-page .chat-layout.has-active-chat .chat-form {
        margin: 0;
        border-radius: 14px;
        padding: 8px;
    }

    body.messages-page .chat-layout.has-active-chat #message-text {
        min-height: 40px;
        max-height: 112px;
    }

    body.messages-page .chat-layout.has-active-chat .chat-composer-row .icon-btn {
        width: 36px;
        height: 36px;
    }
}

body.theme-dark.messages-page .chat-layout.has-active-chat .chat-main {
    border-color: rgba(92, 128, 158, 0.52);
    background:
        radial-gradient(120% 90% at 10% -15%, rgba(226, 111, 73, 0.22), transparent 58%),
        radial-gradient(95% 80% at 100% 0%, rgba(14, 164, 126, 0.17), transparent 58%),
        linear-gradient(180deg, rgba(15, 33, 48, 0.96), rgba(9, 24, 37, 0.97));
}

body.theme-dark.messages-page .chat-layout.has-active-chat .chat-header {
    border-bottom-color: rgba(102, 136, 165, 0.45);
    background: linear-gradient(180deg, rgba(20, 43, 62, 0.78), rgba(15, 34, 50, 0.68));
}

body.theme-dark.messages-page .chat-layout.has-active-chat .chat-status {
    color: #94b7d6;
}

body.theme-dark.messages-page .chat-layout.has-active-chat .messages-list {
    background: linear-gradient(180deg, rgba(12, 27, 40, 0.55), rgba(10, 24, 36, 0.2));
    scrollbar-color: rgba(122, 160, 193, 0.42) transparent;
}

body.theme-dark.messages-page .chat-layout.has-active-chat .bubble {
    border-color: rgba(107, 143, 173, 0.56);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.32);
}

body.theme-dark.messages-page .chat-layout.has-active-chat .bubble.theirs {
    background: linear-gradient(160deg, rgba(26, 48, 68, 0.96), rgba(19, 39, 57, 0.95));
}

body.theme-dark.messages-page .chat-layout.has-active-chat .bubble.theirs::after {
    background: rgba(23, 44, 63, 0.96);
    border-left-color: rgba(107, 143, 173, 0.56);
    border-bottom-color: rgba(107, 143, 173, 0.56);
}

body.theme-dark.messages-page .chat-layout.has-active-chat .bubble.mine {
    border-color: rgba(255, 152, 114, 0.58);
    background: linear-gradient(140deg, rgba(116, 63, 45, 0.94), rgba(92, 50, 36, 0.94));
    color: #ffe4d8;
    box-shadow: 0 13px 25px rgba(0, 0, 0, 0.36);
}

body.theme-dark.messages-page .chat-layout.has-active-chat .bubble.mine::after {
    background: rgba(96, 52, 38, 0.95);
    border-right-color: rgba(255, 152, 114, 0.58);
    border-bottom-color: rgba(255, 152, 114, 0.58);
}

body.theme-dark.messages-page .chat-layout.has-active-chat .bubble-head {
    color: #cde4f8;
}

body.theme-dark.messages-page .chat-layout.has-active-chat .bubble-head small {
    color: #9ec0dc;
}

body.theme-dark.messages-page .chat-layout.has-active-chat .reaction-chip,
body.theme-dark.messages-page .chat-layout.has-active-chat .quick-react-btn,
body.theme-dark.messages-page .chat-layout.has-active-chat .chat-composer-row .icon-btn,
body.theme-dark.messages-page .chat-layout.has-active-chat .emoji-insert-btn {
    border-color: rgba(97, 134, 166, 0.56);
    background: rgba(24, 47, 67, 0.92);
    color: #deeeff;
}

body.theme-dark.messages-page .chat-layout.has-active-chat .chat-form,
body.theme-dark.messages-page .chat-layout.has-active-chat .emoji-picker,
body.theme-dark.messages-page .chat-layout.has-active-chat .bot-helper-card,
body.theme-dark.messages-page .chat-layout.has-active-chat .shared-post-card {
    border-color: rgba(96, 133, 164, 0.56);
    background: linear-gradient(180deg, rgba(17, 37, 54, 0.95), rgba(12, 29, 43, 0.94));
}

body.theme-dark.messages-page .chat-layout.has-active-chat #message-text {
    border-color: rgba(100, 138, 170, 0.58);
    background: rgba(13, 30, 45, 0.95);
    color: #eaf4ff;
}

body.theme-dark.messages-page .chat-layout.has-active-chat #message-text:focus {
    border-color: #ff8f6a;
    box-shadow: 0 0 0 4px rgba(255, 127, 89, 0.2);
}

body.theme-dark.messages-page .chat-layout.has-active-chat .chat-mobile-back {
    border-color: rgba(97, 134, 166, 0.56);
    background: rgba(24, 47, 67, 0.92);
    color: #deeeff;
}

/* Conversation focus mode: hide bottom 5 mobile nav buttons while chatting */
body.messages-page.conversation-open .mobile-tabbar {
    display: none !important;
}

body.messages-page .message-state-row {
    display: flex;
    justify-content: flex-end;
    margin-top: 2px;
}

body.messages-page .message-state {
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.2px;
    color: #9a6f60;
}

body.messages-page .message-state.seen {
    color: #159572;
}

body.messages-page .bubble-live-mine {
    animation: bubbleLiveMine 220ms ease;
}

body.messages-page .bubble-live-theirs {
    animation: bubbleLiveTheirs 220ms ease;
}

@keyframes bubbleLiveMine {
    from {
        opacity: 0;
        transform: translate(8px, 8px) scale(0.985);
    }

    to {
        opacity: 1;
        transform: translate(0, 0) scale(1);
    }
}

@keyframes bubbleLiveTheirs {
    from {
        opacity: 0;
        transform: translate(-8px, 8px) scale(0.985);
    }

    to {
        opacity: 1;
        transform: translate(0, 0) scale(1);
    }
}

@media (max-width: 900px) {
    body.messages-page.conversation-open.is-authenticated .page-shell {
        padding-bottom: calc(8px + env(safe-area-inset-bottom));
    }

    body.messages-page.conversation-open.is-authenticated .chat-layout {
        height: calc(100dvh - 90px);
        min-height: calc(100dvh - 90px);
        max-height: calc(100dvh - 90px);
    }

    body.messages-page.conversation-open.is-authenticated .chat-layout.has-active-chat .chat-form {
        bottom: calc(8px + env(safe-area-inset-bottom));
    }
}

body.theme-dark.messages-page .message-state {
    color: #dba98f;
}

body.theme-dark.messages-page .message-state.seen {
    color: #54cfab;
}
/* Mobile conversation focus lock (final override) */
@media (max-width: 900px) {
    body.messages-page.conversation-open.is-authenticated .topbar,
    body.messages-page.conversation-open.is-authenticated .footer,
    body.messages-page.conversation-open.is-authenticated .mobile-tabbar {
        display: none !important;
    }

    body.messages-page.conversation-open.is-authenticated .page-shell {
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 0 calc(8px + env(safe-area-inset-bottom)) !important;
    }

    body.messages-page.conversation-open.is-authenticated .chat-layout {
        height: 100dvh !important;
        min-height: 100dvh !important;
        max-height: 100dvh !important;
        border-radius: 0 !important;
        padding: 0 !important;
        gap: 0 !important;
        overflow: hidden !important;
    }

    body.messages-page.conversation-open.is-authenticated .chat-main {
        border-radius: 0 !important;
        border: none !important;
        box-shadow: none !important;
        display: flex !important;
        flex-direction: column !important;
        height: 100% !important;
        min-height: 0 !important;
        padding: 8px 10px 0 !important;
    }

    body.messages-page.conversation-open.is-authenticated .chat-header {
        position: sticky !important;
        top: 0 !important;
        z-index: 12 !important;
        border-radius: 12px !important;
        margin: 0 0 8px !important;
        padding: 8px !important;
    }

    body.messages-page.conversation-open.is-authenticated .chat-header form {
        display: none !important;
    }

    body.messages-page.conversation-open.is-authenticated .chat-mobile-back {
        display: inline-flex !important;
    }

    body.messages-page.conversation-open.is-authenticated .messages-list {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        max-height: none !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        padding: 4px 4px 10px !important;
    }

    body.messages-page.conversation-open.is-authenticated .chat-form {
        position: sticky !important;
        bottom: 0 !important;
        z-index: 13 !important;
        margin: 0 !important;
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
        border-bottom: none !important;
        padding: 8px 10px calc(8px + env(safe-area-inset-bottom)) !important;
    }

    body.messages-page.conversation-open.is-authenticated #message-text {
        min-height: 46px !important;
        max-height: 132px !important;
    }
}
/* Settings polish v2: clearer nav and section intros */
.settings-menu-nav .settings-nav-link {
    display: grid;
    grid-template-columns: 20px minmax(0, 1fr);
    align-items: start;
    gap: 10px;
}

.settings-nav-icon {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: currentColor;
}

.settings-nav-icon .ui-icon {
    width: 18px;
    height: 18px;
}

.settings-nav-icon .ui-icon-settings {
    width: 19px;
    height: 19px;
}

.settings-nav-copy {
    min-width: 0;
    display: grid;
    gap: 2px;
}

.settings-nav-copy strong {
    display: block;
    line-height: 1.2;
    font-size: 0.9rem;
}

.settings-nav-copy small {
    display: block;
    color: #5d7f9e;
    font-size: 0.74rem;
    line-height: 1.25;
}

.settings-section-intro {
    margin: -2px 0 2px;
    color: #476d90;
    font-size: 0.84rem;
    line-height: 1.45;
}

body.theme-dark .settings-nav-copy small {
    color: #9dc0dd;
}

body.theme-dark .settings-section-intro {
    color: #a9c7e1;
}

@media (max-width: 520px) {
    .settings-menu-nav .settings-nav-link {
        grid-template-columns: 18px minmax(0, 1fr);
        gap: 8px;
        padding: 8px 10px;
    }

    .settings-nav-copy strong {
        font-size: 0.84rem;
    }

    .settings-nav-copy small {
        font-size: 0.7rem;
    }
}
/* Messaging + Auth mobile finishing pass */
.chat-sidebar-head {
    display: grid;
    gap: 10px;
}

.chat-sidebar-title-row {
    margin-bottom: 0;
}

.chat-subtitle {
    margin-top: 3px;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 700;
}

.chat-contact-search-wrap {
    display: grid;
    gap: 6px;
}

.chat-input-label {
    font-size: 0.73rem;
    color: #587797;
    font-weight: 800;
    letter-spacing: 0.25px;
}

.chat-contact-search {
    width: 100%;
    border: 1px solid #cedeed;
    border-radius: 999px;
    padding: 10px 14px;
    background: linear-gradient(180deg, #ffffff, #f4f9ff);
    color: #173a5a;
    font: inherit;
}

.chat-contact-search:focus {
    outline: none;
    border-color: #ff9873;
    box-shadow: 0 0 0 4px rgba(255, 127, 89, 0.16);
}

.chat-contact-empty {
    margin-top: 4px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px dashed #cfdeec;
    background: #f7fbff;
}

.chat-local-status {
    min-height: 18px;
    font-weight: 700;
    letter-spacing: 0.15px;
}

.chat-local-status.is-sending {
    color: #1f6a9a;
}

.chat-local-status.is-ok {
    color: #118563;
}

.chat-local-status.is-error {
    color: #b54a3a;
}

.chat-local-status.is-hint {
    color: #577693;
}

body.messages-page .bubble-head strong {
    display: none;
}

body.messages-page .bubble.is-bot-message .bubble-head strong {
    display: inline-flex;
}

body.messages-page .bubble.is-bot-message {
    border-color: rgba(72, 168, 214, 0.42);
    background: linear-gradient(155deg, rgba(232, 248, 255, 0.98), rgba(221, 243, 255, 0.96));
}

body.messages-page .bubble.is-bot-message .bubble-head small {
    color: #2f6f98;
}

body.messages-page .chat-header-follow {
    margin: 0;
}

body.messages-page .chat-form textarea {
    line-height: 1.35;
}

@media (max-width: 900px) {
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .chat-sidebar {
        border-radius: 20px;
        border: 1px solid rgba(172, 198, 221, 0.6);
        background: linear-gradient(180deg, rgba(250, 253, 255, 0.96), rgba(239, 248, 255, 0.94));
        box-shadow: 0 18px 36px rgba(12, 39, 62, 0.15);
        padding: 12px;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .chat-head-actions {
        display: inline-flex;
        gap: 6px;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .chat-head-actions a {
        padding: 6px 10px;
        border-radius: 999px;
        font-size: 0.74rem;
        font-weight: 800;
        border: 1px solid #d0dfed;
        background: #f5faff;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link {
        border-radius: 18px;
        border: 1px solid #d6e5f3;
        background: linear-gradient(180deg, #fbfdff, #f2f8ff);
        box-shadow: 0 8px 18px rgba(16, 44, 67, 0.08);
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link.active {
        border-color: #ffb39a;
        background: linear-gradient(130deg, #fff2ec, #ffe7dd);
    }

    body.messages-page.conversation-open.is-authenticated .chat-main {
        padding: 8px 10px 0 !important;
        background:
            radial-gradient(130% 92% at 8% -24%, rgba(255, 124, 88, 0.18), transparent 58%),
            radial-gradient(96% 78% at 100% 0%, rgba(18, 184, 141, 0.15), transparent 58%),
            linear-gradient(180deg, rgba(250, 253, 255, 0.98), rgba(240, 248, 255, 0.96)) !important;
    }

    body.messages-page.conversation-open.is-authenticated .chat-header {
        margin: 0 0 6px !important;
        padding: 8px 9px !important;
        border-radius: 14px !important;
        border: 1px solid rgba(174, 199, 220, 0.56);
        background: linear-gradient(180deg, rgba(255, 255, 255, 0.83), rgba(246, 251, 255, 0.72));
        box-shadow: 0 8px 16px rgba(13, 37, 57, 0.09);
    }

    body.messages-page.conversation-open.is-authenticated .chat-header-follow {
        display: none;
    }

    body.messages-page.conversation-open.is-authenticated .chat-header h2 {
        font-size: 0.93rem;
    }

    body.messages-page.conversation-open.is-authenticated .chat-status {
        font-size: 0.67rem;
    }

    body.messages-page.conversation-open.is-authenticated .messages-list {
        padding: 8px 2px 8px !important;
        gap: 8px;
    }

    body.messages-page.conversation-open.is-authenticated .bubble {
        max-width: 90%;
        border-radius: 17px;
        padding: 9px 11px;
    }

    body.messages-page.conversation-open.is-authenticated .bubble p {
        font-size: 0.91rem;
    }

    body.messages-page.conversation-open.is-authenticated .bubble-head {
        margin-bottom: 1px;
    }

    body.messages-page.conversation-open.is-authenticated .quick-react-row {
        gap: 5px;
        opacity: 0.75;
    }

    body.messages-page.conversation-open.is-authenticated .quick-react-btn {
        width: 24px;
        height: 24px;
        border-radius: 999px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        font-size: 0.78rem;
    }

    body.messages-page.conversation-open.is-authenticated .chat-form {
        border-top: 1px solid rgba(172, 198, 219, 0.7) !important;
        background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(243, 249, 255, 0.9)) !important;
        box-shadow: 0 -12px 24px rgba(10, 34, 54, 0.1);
    }

    body.messages-page.conversation-open.is-authenticated #message-text {
        border-radius: 20px !important;
        min-height: 42px !important;
        max-height: 120px !important;
        padding: 11px 13px;
    }

    body.messages-page.conversation-open.is-authenticated .chat-composer-row {
        gap: 8px;
    }

    body.messages-page.conversation-open.is-authenticated .chat-composer-row .icon-btn {
        width: 36px;
        height: 36px;
        border-radius: 999px;
    }

    body.messages-page.conversation-open.is-authenticated .bot-helper-card {
        border-radius: 14px;
        padding: 9px;
    }

    body.messages-page.conversation-open.is-authenticated .bot-prompt-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

body.theme-dark .chat-input-label {
    color: #9ebbd6;
}

body.theme-dark .chat-contact-search {
    border-color: #456582;
    background: linear-gradient(180deg, #183550, #142c42);
    color: #eaf3ff;
}

body.theme-dark .chat-contact-empty {
    border-color: #486987;
    background: rgba(24, 47, 68, 0.9);
}

body.theme-dark .chat-local-status.is-hint {
    color: #a6c2db;
}

body.theme-dark .chat-local-status.is-sending {
    color: #8ec4ec;
}

body.theme-dark .chat-local-status.is-ok {
    color: #6fd7b2;
}

body.theme-dark .chat-local-status.is-error {
    color: #ffb5a2;
}

body.theme-dark.messages-page .bubble.is-bot-message {
    border-color: rgba(100, 156, 194, 0.5);
    background: linear-gradient(160deg, rgba(27, 52, 74, 0.95), rgba(20, 43, 62, 0.94));
}

.auth-card-subtitle {
    margin: -4px 0 12px;
    color: #577596;
    font-size: 0.9rem;
}

.auth-password-wrap {
    position: relative;
    display: grid;
    align-items: center;
}

.auth-password-wrap input {
    padding-right: 74px;
}

.auth-password-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    border: 1px solid #cfe0ef;
    border-radius: 999px;
    background: #f4f9ff;
    color: #1b4b72;
    font-size: 0.72rem;
    font-weight: 800;
    padding: 5px 10px;
    cursor: pointer;
}

.auth-password-toggle:hover {
    background: #e9f3ff;
}

.auth-switch-stack {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.auth-register-wizard {
    gap: 14px;
}

.auth-wizard-topline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.auth-wizard-topline .auth-wizard-step-label {
    text-align: left;
}

.auth-wizard-step-label {
    margin: 0;
    text-align: center;
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0.4px;
    color: #2f638f;
}

.auth-step-skip {
    min-height: 32px;
    padding: 6px 11px;
    font-size: 0.72rem;
}

.auth-wizard-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 6px 0 2px;
}

.auth-wizard-dot {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    border: 1px solid #c9dbee;
    background: #f6fbff;
    color: #2b5e8a;
    font-weight: 800;
    font-size: 0.78rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 180ms ease;
}

.auth-wizard-dot.is-active {
    border-color: #4d8ec3;
    background: linear-gradient(140deg, #dff0ff, #ebf7ff);
    box-shadow: 0 0 0 3px rgba(95, 152, 204, 0.2);
}

.auth-wizard-dot.is-complete {
    border-color: #80b1db;
    background: linear-gradient(140deg, #c6e8ff, #dff2ff);
    color: #1f4f79;
}

.auth-wizard-step {
    display: grid;
    gap: 10px;
}

.auth-wizard-step[hidden] {
    display: none !important;
}

.auth-wizard-step h3 {
    margin: 0;
    font-size: 1rem;
    color: #1e4d76;
}

.auth-wizard-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.auth-wizard-actions .primary-btn {
    margin-left: auto;
}

.auth-step-error {
    margin: 0;
    color: #8c341f;
    background: #ffe8de;
    border: 1px solid #ffd0bf;
    border-radius: 12px;
    padding: 8px 10px;
    font-size: 0.84rem;
    font-weight: 700;
}

body.auth-body .auth-card {
    border-radius: 22px;
}

body.auth-body .auth-card .primary-btn,
body.auth-body .auth-card .secondary-btn {
    min-height: 44px;
}

@media (max-width: 900px) {
    body.auth-body .auth-wrap {
        min-height: calc(100vh - 142px);
        gap: 14px;
    }

    body.auth-body .auth-hero {
        padding: 6px;
    }

    body.auth-body .auth-hero h1 {
        font-size: clamp(1.75rem, 7.5vw, 2.5rem);
    }

    body.auth-body .auth-card {
        padding: 18px 14px;
    }

    body.auth-body .auth-card-subtitle {
        font-size: 0.84rem;
    }

    body.auth-body .auth-password-wrap input {
        padding-right: 68px;
    }

    body.auth-body .auth-password-toggle {
        right: 7px;
        font-size: 0.68rem;
        padding: 5px 9px;
    }
}

body.theme-dark.auth-body .auth-card-subtitle {
    color: #5c7896;
}

body.theme-dark.auth-body .auth-password-toggle {
    border-color: #3f607d;
    background: #17334b;
    color: #e8f3ff;
}

body.theme-dark.auth-body .auth-password-toggle:hover {
    background: #1d3c56;
}

body.theme-dark.auth-body .auth-wizard-dot {
    border-color: #3c5f7d;
    background: #11293f;
    color: #cfe4f7;
}

body.theme-dark.auth-body .auth-wizard-dot.is-active {
    border-color: #5e8fb8;
    background: linear-gradient(145deg, #173a57, #1b425f);
    box-shadow: 0 0 0 3px rgba(77, 142, 195, 0.26);
}

body.theme-dark.auth-body .auth-wizard-dot.is-complete {
    border-color: #4f7ea8;
    background: linear-gradient(145deg, #19415f, #1b4a69);
    color: #d8ecff;
}

body.theme-dark.auth-body .auth-wizard-step-label {
    color: #b8d6f1;
}

body.theme-dark.auth-body .auth-wizard-step h3 {
    color: #dbeeff;
}

body.theme-dark .post-delete-btn {
    color: #ffb9a9;
    border-color: rgba(214, 129, 108, 0.45);
    background: rgba(109, 42, 32, 0.42);
}

body.theme-dark .post-delete-btn:hover {
    background: rgba(128, 47, 34, 0.5);
    color: #ffd5cc;
}

body.theme-dark.auth-body .auth-step-error {
    color: #ffd4c8;
    border-color: rgba(194, 124, 102, 0.44);
    background: rgba(98, 45, 34, 0.42);
}
/* Build stamp: quick check that latest code is loaded */
.footer .build-stamp {
    display: inline-block;
    margin-top: 4px;
    font-size: 0.68rem;
    letter-spacing: 0.25px;
    opacity: 0.74;
}
/* Final mobile DM + auth stabilization (March 2026) */
body.messages-page .chat-main.chat-main-live {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

body.messages-page .messages-list.messages-list-live {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
}

body.messages-page .chat-form.chat-form-live {
    flex: 0 0 auto;
}

body.messages-page .chat-local-status {
    min-height: 16px;
}

body.messages-page .contact-row-link {
    text-decoration: none;
}

body.messages-page .contact-row-link:focus-visible {
    outline: 2px solid #2f86c9;
    outline-offset: 2px;
}

@media (max-width: 900px) {
    body.messages-page.conversation-open.is-authenticated .topbar,
    body.messages-page.conversation-open.is-authenticated .footer,
    body.messages-page.conversation-open.is-authenticated .mobile-tabbar {
        display: none !important;
    }

    body.messages-page.conversation-open.is-authenticated .page-shell {
        padding: 0 !important;
        margin: 0;
        max-width: none;
    }

    body.messages-page.conversation-open.is-authenticated .chat-layout {
        display: block;
        width: 100vw;
        height: 100dvh;
        margin: 0;
        padding: 0;
        border-radius: 0;
        gap: 0;
    }

    body.messages-page.conversation-open.is-authenticated .chat-main.chat-main-live {
        width: 100vw;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        border: 0;
        margin: 0;
        background: radial-gradient(circle at 15% 12%, rgba(112, 197, 255, 0.18), transparent 56%),
            radial-gradient(circle at 90% 0%, rgba(103, 205, 170, 0.14), transparent 44%),
            linear-gradient(180deg, rgba(246, 251, 255, 0.98), rgba(235, 245, 252, 0.96));
    }

    body.messages-page.conversation-open.is-authenticated .chat-header.chat-header-live {
        position: sticky;
        top: 0;
        z-index: 40;
        display: grid;
        grid-template-columns: auto 1fr;
        align-items: center;
        gap: 10px;
        padding: 10px 12px;
        border-bottom: 1px solid rgba(149, 177, 207, 0.55);
        background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(244, 250, 255, 0.88));
        backdrop-filter: blur(11px);
    }

    body.messages-page.conversation-open.is-authenticated .chat-header-follow {
        display: none !important;
    }

    body.messages-page.conversation-open.is-authenticated .chat-mobile-back {
        display: inline-flex !important;
    }

    body.messages-page.conversation-open.is-authenticated .chat-header-user {
        min-width: 0;
    }

    body.messages-page.conversation-open.is-authenticated .chat-header h2 {
        font-size: 0.95rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    body.messages-page.conversation-open.is-authenticated .chat-status {
        display: block;
        font-size: 0.74rem;
        opacity: 0.8;
    }

    body.messages-page.conversation-open.is-authenticated .messages-list.messages-list-live {
        padding: 12px 12px 8px;
        gap: 9px;
    }

    body.messages-page.conversation-open.is-authenticated .bubble {
        max-width: 88%;
    }

    body.messages-page.conversation-open.is-authenticated .chat-form.chat-form-live {
        position: sticky;
        bottom: 0;
        z-index: 45;
        margin: 0;
        padding: 9px 10px calc(11px + env(safe-area-inset-bottom));
        border-top: 1px solid rgba(149, 177, 207, 0.55);
        background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(243, 249, 255, 0.98));
        backdrop-filter: blur(12px);
    }

    body.messages-page.conversation-open.is-authenticated #message-text {
        min-height: 44px;
        max-height: 116px;
        border-radius: 15px;
        font-size: 0.95rem;
        line-height: 1.35;
    }

    body.messages-page.conversation-open.is-authenticated .chat-composer-row {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    body.messages-page.conversation-open.is-authenticated .chat-composer-row .icon-btn {
        width: 40px;
        height: 40px;
        flex: 0 0 40px;
    }

    body.messages-page.conversation-open.is-authenticated .chat-composer-row .icon-send {
        margin-left: auto;
    }

    body.messages-page.conversation-open.is-authenticated .bot-helper-card {
        margin: 8px 10px 4px;
        border-radius: 16px;
    }
}

@media (max-width: 900px) {
    body.messages-page.is-authenticated:not(.conversation-open) .chat-sidebar {
        border-radius: 20px;
        overflow: hidden;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contacts-list {
        max-height: calc(100dvh - 255px);
    }
}

body.auth-body.theme-dark,
body.auth-body.theme-dark input,
body.auth-body.theme-dark textarea,
body.auth-body.theme-dark select {
    color: #e8f3ff;
}

body.auth-body.theme-dark .auth-card {
    background: linear-gradient(165deg, rgba(10, 28, 45, 0.9), rgba(14, 39, 61, 0.86));
    border-color: rgba(140, 184, 218, 0.34);
    box-shadow: 0 28px 52px rgba(5, 15, 25, 0.45);
}

body.auth-body.theme-dark .auth-card-subtitle,
body.auth-body.theme-dark .switch-text,
body.auth-body.theme-dark .switch-text a {
    color: rgba(198, 219, 238, 0.88);
}

body.auth-body.theme-dark .auth-password-toggle {
    border-color: rgba(139, 184, 219, 0.42);
    background: rgba(9, 25, 39, 0.68);
    color: #e9f4ff;
}

body.auth-body.theme-dark .auth-password-toggle:hover {
    background: rgba(15, 35, 53, 0.82);
}
/* Chatbot bottom prompts + theme sync + larger message viewport */
body.messages-page .bot-helper-card-bottom {
    margin: 4px 8px 2px;
    padding: 5px 6px;
    border-radius: 12px;
    border: 1px solid rgba(170, 197, 220, 0.56);
    background: linear-gradient(180deg, rgba(247, 252, 255, 0.84), rgba(241, 248, 255, 0.72));
    box-shadow: none;
}

body.messages-page .bot-helper-card-bottom .bot-prompt-row-compact {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: thin;
    padding-bottom: 1px;
}

body.messages-page .bot-helper-card-bottom .bot-prompt-btn {
    flex: 0 0 auto;
    font-size: 0.66rem;
    font-weight: 700;
    padding: 4px 8px;
    min-height: 24px;
    border-radius: 999px;
    line-height: 1.1;
}

body.messages-page .messages-list.messages-list-live {
    padding: 10px 10px 6px;
}

@media (max-width: 900px) {
    body.messages-page.conversation-open.is-authenticated .chat-header.chat-header-live {
        padding: 8px 10px;
        gap: 8px;
    }

    body.messages-page.conversation-open.is-authenticated .messages-list.messages-list-live {
        padding: 8px 10px 4px;
        gap: 8px;
    }

    body.messages-page.conversation-open.is-authenticated .bot-helper-card-bottom {
        margin: 2px 8px 2px;
        padding: 4px 5px;
    }

    body.messages-page.conversation-open.is-authenticated .chat-form.chat-form-live {
        padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
    }

    body.messages-page.conversation-open.is-authenticated #message-text {
        min-height: 38px;
        max-height: 96px;
        border-radius: 13px;
        padding-top: 10px;
        padding-bottom: 10px;
    }

    body.messages-page.conversation-open.is-authenticated .chat-composer-row .icon-btn {
        width: 36px;
        height: 36px;
        flex: 0 0 36px;
    }
}

body.theme-dark.messages-page.conversation-open.is-authenticated .chat-main.chat-main-live {
    background:
        radial-gradient(circle at 14% 10%, rgba(95, 170, 225, 0.18), transparent 56%),
        radial-gradient(circle at 92% 0%, rgba(66, 150, 124, 0.17), transparent 44%),
        linear-gradient(180deg, rgba(14, 31, 46, 0.97), rgba(10, 24, 36, 0.98));
}

body.theme-dark.messages-page.conversation-open.is-authenticated .chat-header.chat-header-live {
    border-bottom-color: rgba(98, 132, 161, 0.6);
    background: linear-gradient(180deg, rgba(20, 43, 62, 0.88), rgba(15, 35, 52, 0.78));
}

body.theme-dark.messages-page.conversation-open.is-authenticated .messages-list.messages-list-live {
    background: linear-gradient(180deg, rgba(10, 24, 36, 0.54), rgba(9, 21, 31, 0.15));
}

body.theme-dark.messages-page.conversation-open.is-authenticated .chat-form.chat-form-live {
    border-top-color: rgba(98, 132, 161, 0.58);
    background: linear-gradient(180deg, rgba(18, 40, 58, 0.9), rgba(12, 29, 44, 0.95));
}

body.theme-dark.messages-page.conversation-open.is-authenticated #message-text {
    background: rgba(12, 28, 42, 0.9);
    border-color: rgba(95, 132, 163, 0.65);
    color: #e8f3ff;
}

body.theme-dark.messages-page.conversation-open.is-authenticated #message-text::placeholder {
    color: #91b2cf;
}

body.theme-dark.messages-page .bot-helper-card-bottom {
    border-color: rgba(95, 132, 162, 0.58);
    background: linear-gradient(180deg, rgba(20, 42, 60, 0.88), rgba(15, 33, 49, 0.8));
}

body.theme-dark.messages-page .bot-helper-card-bottom .bot-prompt-btn {
    border-color: rgba(95, 133, 164, 0.68);
    background: rgba(16, 35, 52, 0.9);
    color: #dff0ff;
}

body.theme-dark.messages-page .bot-helper-card-bottom .bot-prompt-btn:hover {
    background: rgba(21, 44, 64, 0.96);
}
/* Hard fix: conversation backgrounds must never stay plain white */
body.messages-page .chat-layout.has-active-chat .chat-main.chat-main-live,
body.messages-page.conversation-open.is-authenticated .chat-main.chat-main-live {
    background:
        radial-gradient(circle at 16% 10%, rgba(124, 198, 255, 0.2), transparent 55%),
        radial-gradient(circle at 92% 0%, rgba(117, 216, 184, 0.17), transparent 45%),
        linear-gradient(180deg, #f2f9ff, #e9f3fb) !important;
}

body.messages-page .chat-layout.has-active-chat .messages-list.messages-list-live,
body.messages-page.conversation-open.is-authenticated .messages-list.messages-list-live {
    background: linear-gradient(180deg, rgba(237, 247, 255, 0.82), rgba(228, 240, 251, 0.58)) !important;
}

body.messages-page .chat-layout.has-active-chat .bubble.theirs {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(245, 251, 255, 0.95)) !important;
    border-color: rgba(171, 198, 221, 0.72) !important;
}

body.theme-dark.messages-page .chat-layout.has-active-chat .chat-main.chat-main-live,
body.theme-dark.messages-page.conversation-open.is-authenticated .chat-main.chat-main-live {
    background:
        radial-gradient(circle at 16% 10%, rgba(90, 164, 219, 0.23), transparent 58%),
        radial-gradient(circle at 92% 0%, rgba(69, 150, 126, 0.2), transparent 46%),
        linear-gradient(180deg, rgba(13, 30, 45, 0.98), rgba(9, 23, 35, 0.99)) !important;
}

body.theme-dark.messages-page .chat-layout.has-active-chat .messages-list.messages-list-live,
body.theme-dark.messages-page.conversation-open.is-authenticated .messages-list.messages-list-live {
    background: linear-gradient(180deg, rgba(10, 24, 36, 0.62), rgba(8, 20, 30, 0.28)) !important;
}

body.theme-dark.messages-page .chat-layout.has-active-chat .chat-header.chat-header-live,
body.theme-dark.messages-page .chat-layout.has-active-chat .chat-form.chat-form-live,
body.theme-dark.messages-page.conversation-open.is-authenticated .chat-header.chat-header-live,
body.theme-dark.messages-page.conversation-open.is-authenticated .chat-form.chat-form-live {
    background: linear-gradient(180deg, rgba(18, 40, 58, 0.92), rgba(13, 31, 46, 0.96)) !important;
    border-color: rgba(98, 132, 161, 0.62) !important;
}

body.theme-dark.messages-page .chat-layout.has-active-chat .bubble.theirs {
    background: linear-gradient(180deg, rgba(20, 44, 63, 0.94), rgba(16, 36, 53, 0.92)) !important;
    border-color: rgba(101, 136, 166, 0.62) !important;
}
/* Hard fix: conversations list area (sidebar) should never be plain white */
body.messages-page .chat-sidebar {
    background:
        radial-gradient(circle at 10% 0%, rgba(125, 200, 255, 0.18), transparent 52%),
        linear-gradient(180deg, rgba(246, 252, 255, 0.98), rgba(236, 246, 255, 0.96)) !important;
    border-color: rgba(160, 190, 214, 0.56) !important;
}

body.messages-page .chat-sidebar-head {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(245, 252, 255, 0.68)) !important;
    border-bottom: 1px solid rgba(173, 199, 221, 0.56) !important;
}

body.messages-page .contacts-list {
    background: linear-gradient(180deg, rgba(244, 251, 255, 0.74), rgba(234, 245, 253, 0.62)) !important;
}

body.messages-page .contact-item {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(246, 251, 255, 0.93)) !important;
    border-color: rgba(172, 198, 220, 0.62) !important;
}

body.messages-page .contact-item.active {
    background: linear-gradient(180deg, rgba(235, 246, 255, 0.98), rgba(223, 239, 252, 0.96)) !important;
    border-color: rgba(120, 167, 203, 0.7) !important;
}

body.messages-page .chat-contact-search {
    background: rgba(255, 255, 255, 0.92) !important;
    border-color: rgba(168, 196, 219, 0.64) !important;
}

body.theme-dark.messages-page .chat-sidebar {
    background:
        radial-gradient(circle at 10% 0%, rgba(88, 161, 215, 0.22), transparent 56%),
        linear-gradient(180deg, rgba(14, 31, 46, 0.97), rgba(10, 24, 36, 0.98)) !important;
    border-color: rgba(96, 131, 160, 0.62) !important;
}

body.theme-dark.messages-page .chat-sidebar-head {
    background: linear-gradient(180deg, rgba(20, 42, 61, 0.88), rgba(15, 34, 50, 0.8)) !important;
    border-bottom-color: rgba(96, 131, 160, 0.6) !important;
}

body.theme-dark.messages-page .contacts-list {
    background: linear-gradient(180deg, rgba(11, 25, 37, 0.66), rgba(8, 20, 30, 0.4)) !important;
}

body.theme-dark.messages-page .contact-item {
    background: linear-gradient(180deg, rgba(19, 41, 60, 0.93), rgba(14, 33, 49, 0.91)) !important;
    border-color: rgba(96, 132, 161, 0.64) !important;
}

body.theme-dark.messages-page .contact-item.active {
    background: linear-gradient(180deg, rgba(31, 61, 86, 0.96), rgba(24, 50, 73, 0.94)) !important;
    border-color: rgba(121, 166, 203, 0.82) !important;
}

body.theme-dark.messages-page .chat-contact-search {
    background: rgba(14, 31, 46, 0.9) !important;
    border-color: rgba(95, 132, 162, 0.7) !important;
    color: #e4f1ff !important;
}
/* ZerinoBot identity: no human profile avatar, only bot mark */
.bot-avatar-shell {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(140deg, #0f5f94, #17a989) !important;
    border: 1px solid rgba(20, 106, 153, 0.45) !important;
    color: #ffffff !important;
    box-shadow: 0 6px 14px rgba(7, 40, 62, 0.22);
}

.bot-avatar-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 0.68rem;
    font-weight: 900;
    letter-spacing: 0.5px;
}

.chat-header-user-bot {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    text-decoration: none;
    cursor: default;
}

body.theme-dark .bot-avatar-shell {
    background: linear-gradient(140deg, #2c79ac, #1ca988) !important;
    border-color: rgba(102, 157, 193, 0.56) !important;
}


body.theme-dark .curriculum-controls label,
body.theme-dark .curriculum-subjects-title,
body.theme-dark .na-country-card h5 {
    color: #dceeff;
}

body.theme-dark .curriculum-region-title {
    color: #dceeff;
}



body.theme-dark .resources-doc-library,
body.theme-dark .resource-doc-item {
    background: rgba(18, 39, 57, 0.88);
    border-color: rgba(127, 165, 198, 0.34);
    color: var(--text);
}

body.theme-dark .resources-doc-type-tabs .mini-btn {
    background: rgba(26, 51, 73, 0.9);
    border-color: rgba(124, 162, 196, 0.32);
    color: #e8f3ff;
}

body.theme-dark .resources-doc-type-tabs .mini-btn.is-active {
    background: rgba(107, 56, 39, 0.55);
    border-color: rgba(255, 154, 115, 0.5);
    color: #ffdacc;
}

/* Voice/Video call UI */
.chat-call-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    margin-right: 6px;
}

.chat-call-actions .icon-btn {
    width: 34px;
    height: 34px;
}

.call-overlay {
    position: fixed;
    inset: 0;
    z-index: 340;
    display: grid;
    place-items: center;
    background: rgba(7, 17, 28, 0.72);
    padding: 18px;
}

.call-overlay[hidden] {
    display: none !important;
}

.call-card {
    width: min(720px, 96vw);
    border-radius: 18px;
    border: 1px solid #d4e4f2;
    background: #f7fbff;
    box-shadow: 0 24px 54px rgba(11, 31, 49, 0.28);
    padding: 12px;
    display: grid;
    gap: 10px;
}

.call-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.call-media {
    position: relative;
    border-radius: 14px;
    overflow: hidden;
    background: #0f1a26;
    min-height: 280px;
}

.call-remote-video {
    width: 100%;
    min-height: 280px;
    max-height: 58vh;
    object-fit: cover;
    background: #0d1722;
}

.call-local-video {
    position: absolute;
    right: 10px;
    bottom: 10px;
    width: 128px;
    height: 86px;
    border-radius: 10px;
    object-fit: cover;
    border: 1px solid rgba(238, 247, 255, 0.45);
    background: #101d2c;
}

.call-incoming-box {
    border: 1px solid #cde0f0;
    background: #eef6ff;
    border-radius: 12px;
    padding: 10px;
    display: grid;
    gap: 8px;
}

.call-incoming-box p {
    margin: 0;
}

.call-incoming-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.call-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.call-controls .mini-btn.danger {
    border-color: #f0b4b4;
    color: #8f1d1d;
    background: #fff3f3;
}

body.theme-dark .call-overlay {
    background: rgba(2, 8, 14, 0.8);
}

body.theme-dark .call-card {
    border-color: rgba(110, 149, 182, 0.35);
    background: #12283c;
    box-shadow: 0 24px 54px rgba(0, 0, 0, 0.45);
}

body.theme-dark .call-incoming-box {
    border-color: rgba(110, 149, 182, 0.35);
    background: rgba(15, 45, 69, 0.84);
}

body.theme-dark .call-controls .mini-btn.danger {
    border-color: rgba(221, 113, 113, 0.45);
    color: #ffd8d8;
    background: rgba(120, 35, 35, 0.35);
}

@media (max-width: 900px) {
    .chat-call-actions {
        margin-right: 2px;
    }

    .chat-call-actions .icon-btn {
        width: 32px;
        height: 32px;
    }

    .call-card {
        width: 100%;
        border-radius: 14px;
        padding: 10px;
    }

    .call-media,
    .call-remote-video {
        min-height: 220px;
    }

    .call-local-video {
        width: 108px;
        height: 74px;
    }
}

/* Messages list real mobile size - absolute final override */
@media (max-width: 900px) {
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contacts-list,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contacts-list {
        padding: 4px !important;
        gap: 5px !important;
        align-content: start !important;
        justify-content: start !important;
        align-items: start !important;
        grid-auto-rows: min-content !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item,
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link {
        display: grid !important;
        grid-template-columns: 30px minmax(0, 1fr) auto !important;
        align-items: center !important;
        align-self: start !important;
        min-height: 52px !important;
        height: auto !important;
        max-height: none !important;
        padding: 6px 8px !important;
        gap: 8px !important;
        border-radius: 10px !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item .avatar,
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link .avatar,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item .avatar,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link .avatar {
        width: 30px !important;
        height: 30px !important;
        font-size: 0.72rem !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta-top,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta-top {
        gap: 6px !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta-top strong,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta-top strong {
        font-size: 0.86rem !important;
        line-height: 1.15 !important;
        min-width: 0 !important;
        overflow: hidden !important;
        white-space: nowrap !important;
        text-overflow: ellipsis !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-time,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-time {
        font-size: 0.66rem !important;
        line-height: 1 !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta > small.muted,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta > small.muted {
        display: none !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta p,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta p {
        margin: 2px 0 0 !important;
        font-size: 0.76rem !important;
        line-height: 1.2 !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 1 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item .badge,
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link .badge,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item .badge,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link .badge {
        min-width: 14px !important;
        height: 14px !important;
        padding: 0 3px !important;
        font-size: 0.58rem !important;
        line-height: 14px !important;
    }
}

@media (max-width: 520px) {
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item,
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link {
        grid-template-columns: 28px minmax(0, 1fr) auto !important;
        min-height: 48px !important;
        padding: 5px 7px !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item .avatar,
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link .avatar,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item .avatar,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link .avatar {
        width: 28px !important;
        height: 28px !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta-top strong,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta-top strong {
        font-size: 0.82rem !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta p,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta p {
        font-size: 0.74rem !important;
    }
}

/* ========== ABSOLUTE EOF OVERRIDE: AUTH + MESSAGES MOBILE ========== */
@media (max-width: 900px) {
    html.is-handheld body.auth-body .auth-wrap,
    body.auth-body .auth-wrap {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 10px !important;
        align-items: start !important;
        min-height: auto !important;
    }

    html.is-handheld body.auth-body .auth-wrap > *,
    body.auth-body .auth-wrap > * {
        min-width: 0 !important;
        max-width: 100% !important;
    }

    html.is-handheld body.auth-body .auth-hero,
    body.auth-body .auth-hero {
        order: 1 !important;
        max-width: 100% !important;
        padding: 10px 8px !important;
    }

    html.is-handheld body.auth-body .auth-card,
    body.auth-body .auth-card {
        order: 2 !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 14px 12px !important;
        border-radius: 16px !important;
        overflow: hidden !important;
    }

    html.is-handheld body.auth-body .auth-card h2,
    body.auth-body .auth-card h2 {
        font-size: 1.9rem !important;
        line-height: 1.05 !important;
        margin-bottom: 10px !important;
    }

    html.is-handheld body.auth-body input,
    html.is-handheld body.auth-body textarea,
    html.is-handheld body.auth-body select,
    body.auth-body input,
    body.auth-body textarea,
    body.auth-body select {
        width: 100% !important;
        max-width: 100% !important;
        padding: 9px 10px !important;
        font-size: 0.9rem !important;
    }

    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contacts-list,
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contacts-list {
        padding: 4px !important;
        gap: 5px !important;
        align-content: start !important;
        justify-content: start !important;
        align-items: start !important;
        grid-auto-rows: min-content !important;
    }

    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link,
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item,
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link {
        display: grid !important;
        grid-template-columns: 30px minmax(0, 1fr) auto !important;
        min-height: 52px !important;
        padding: 6px 8px !important;
        gap: 8px !important;
        border-radius: 10px !important;
        align-items: center !important;
        align-self: start !important;
        height: auto !important;
        max-height: none !important;
    }

    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item .avatar,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link .avatar,
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item .avatar,
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link .avatar {
        width: 30px !important;
        height: 30px !important;
        font-size: 0.72rem !important;
    }

    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta-top strong,
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta-top strong {
        font-size: 0.86rem !important;
        line-height: 1.15 !important;
    }

    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-time,
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-time {
        font-size: 0.66rem !important;
        line-height: 1 !important;
    }

    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta p,
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta p {
        margin: 2px 0 0 !important;
        font-size: 0.76rem !important;
        line-height: 1.2 !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 1 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
    }

    html.is-handheld body.messages-page.conversation-open.is-authenticated .messages-list,
    html.is-handheld body.messages-page.conversation-open.is-authenticated .messages-list.messages-list-live,
    body.messages-page.conversation-open.is-authenticated .messages-list,
    body.messages-page.conversation-open.is-authenticated .messages-list.messages-list-live {
        align-content: start !important;
        justify-content: start !important;
        align-items: start !important;
        grid-auto-rows: min-content !important;
    }

    html.is-handheld body.messages-page.conversation-open.is-authenticated .bubble,
    body.messages-page.conversation-open.is-authenticated .bubble {
        align-self: start !important;
        height: auto !important;
        max-height: none !important;
    }

    html.is-handheld body.messages-page .bubble-head strong,
    body.messages-page .bubble-head strong {
        display: inline-flex !important;
    }
}

@media (max-width: 520px) {
    html.is-handheld body.auth-body .auth-card h2,
    body.auth-body .auth-card h2 {
        font-size: 1.7rem !important;
    }

    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link,
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item,
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link {
        grid-template-columns: 28px minmax(0, 1fr) auto !important;
        min-height: 48px !important;
        padding: 5px 7px !important;
    }
}

/* EOF lock: clean contact rows for mobile conversations list */
@media (max-width: 900px) {
    body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contacts-list,
    html.is-handheld body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contacts-list {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        justify-content: flex-start !important;
        align-content: flex-start !important;
        gap: 8px !important;
        padding: 8px !important;
        grid-auto-rows: auto !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-item,
    body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-row-link,
    html.is-handheld body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-item,
    html.is-handheld body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-row-link {
        display: grid !important;
        grid-template-columns: 40px minmax(0, 1fr) auto !important;
        align-items: center !important;
        min-height: 72px !important;
        height: auto !important;
        max-height: none !important;
        padding: 10px 11px !important;
        gap: 10px !important;
        border-radius: 14px !important;
        align-self: auto !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-item .avatar,
    body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-row-link .avatar,
    html.is-handheld body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-item .avatar,
    html.is-handheld body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-row-link .avatar {
        width: 40px !important;
        height: 40px !important;
        font-size: 0.96rem !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-meta,
    html.is-handheld body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-meta {
        display: flex !important;
        flex-direction: column !important;
        gap: 4px !important;
        min-width: 0 !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-meta-top,
    html.is-handheld body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-meta-top {
        display: flex !important;
        align-items: flex-start !important;
        justify-content: space-between !important;
        gap: 8px !important;
        min-width: 0 !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-name-wrap,
    html.is-handheld body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-name-wrap {
        display: inline-flex !important;
        align-items: center !important;
        gap: 6px !important;
        min-width: 0 !important;
        max-width: calc(100% - 60px) !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-name-wrap .name-with-badge,
    html.is-handheld body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-name-wrap .name-with-badge {
        display: inline-flex !important;
        align-items: center !important;
        gap: 4px !important;
        min-width: 0 !important;
        max-width: 100% !important;
        overflow: hidden !important;
        white-space: nowrap !important;
        text-overflow: ellipsis !important;
        font-size: 1rem !important;
        line-height: 1.2 !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-time,
    html.is-handheld body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-time {
        flex: 0 0 auto !important;
        margin-left: 6px !important;
        font-size: 0.75rem !important;
        line-height: 1 !important;
        color: var(--text-muted) !important;
        white-space: nowrap !important;
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        padding: 0 !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-meta > small.muted,
    html.is-handheld body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-meta > small.muted {
        display: block !important;
        margin: 0 !important;
        font-size: 0.75rem !important;
        line-height: 1.1 !important;
        opacity: 0.85 !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-state-text,
    html.is-handheld body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-state-text {
        margin: 0 !important;
        font-size: 0.88rem !important;
        line-height: 1.2 !important;
        color: var(--text-soft) !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
}

@media (max-width: 520px) {
    body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-item,
    body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-row-link,
    html.is-handheld body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-item,
    html.is-handheld body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-row-link {
        grid-template-columns: 38px minmax(0, 1fr) auto !important;
        min-height: 66px !important;
        padding: 9px 10px !important;
        gap: 9px !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-item .avatar,
    body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-row-link .avatar,
    html.is-handheld body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-item .avatar,
    html.is-handheld body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-row-link .avatar {
        width: 38px !important;
        height: 38px !important;
        font-size: 0.92rem !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-name-wrap .name-with-badge,
    html.is-handheld body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-name-wrap .name-with-badge {
        font-size: 0.94rem !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-state-text,
    html.is-handheld body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-state-text {
        font-size: 0.84rem !important;
    }
}

/* Auth + Messages mobile rescue (absolute final) */
@media (max-width: 900px) {
    html.is-handheld body.auth-body .page-shell,
    body.auth-body .page-shell {
        margin: 8px auto 14px !important;
        padding: 0 8px !important;
    }

    html.is-handheld body.auth-body .topbar-inner,
    body.auth-body .topbar-inner {
        padding: 8px 10px !important;
        gap: 8px !important;
    }

    html.is-handheld body.auth-body .brand-mark,
    body.auth-body .brand-mark {
        width: 30px !important;
        height: 30px !important;
        border-radius: 10px !important;
    }

    html.is-handheld body.auth-body .brand-text,
    body.auth-body .brand-text {
        font-size: 0.92rem !important;
    }

    html.is-handheld body.auth-body .top-nav,
    body.auth-body .top-nav {
        gap: 6px !important;
        flex-wrap: wrap !important;
        justify-content: flex-end !important;
    }

    html.is-handheld body.auth-body .top-nav > a,
    html.is-handheld body.auth-body .top-nav button,
    body.auth-body .top-nav > a,
    body.auth-body .top-nav button {
        padding: 6px 9px !important;
        font-size: 0.78rem !important;
        border-radius: 999px !important;
    }

    html.is-handheld body.auth-body .auth-wrap,
    body.auth-body .auth-wrap {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 10px !important;
        align-items: start !important;
        min-height: auto !important;
    }

    html.is-handheld body.auth-body .auth-wrap > *,
    body.auth-body .auth-wrap > * {
        min-width: 0 !important;
        max-width: 100% !important;
    }

    html.is-handheld body.auth-body .auth-hero,
    body.auth-body .auth-hero {
        order: 1;
        max-width: 100% !important;
        padding: 10px 8px !important;
    }

    html.is-handheld body.auth-body .auth-hero h1,
    body.auth-body .auth-hero h1 {
        font-size: clamp(1.7rem, 8vw, 2.2rem) !important;
        line-height: 1.1 !important;
        margin: 8px 0 10px !important;
    }

    html.is-handheld body.auth-body .auth-hero p,
    body.auth-body .auth-hero p {
        font-size: 0.85rem !important;
        line-height: 1.35 !important;
    }

    html.is-handheld body.auth-body .auth-card,
    body.auth-body .auth-card {
        order: 2;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 14px 12px !important;
        border-radius: 16px !important;
        overflow: hidden !important;
    }

    html.is-handheld body.auth-body .auth-card h2,
    body.auth-body .auth-card h2 {
        margin-bottom: 10px !important;
        font-size: 1.9rem !important;
        line-height: 1.05 !important;
    }

    html.is-handheld body.auth-body .auth-card-subtitle,
    body.auth-body .auth-card-subtitle {
        font-size: 0.82rem !important;
        line-height: 1.3 !important;
    }

    html.is-handheld body.auth-body .stack-form,
    body.auth-body .stack-form {
        gap: 8px !important;
    }

    html.is-handheld body.auth-body input,
    html.is-handheld body.auth-body textarea,
    html.is-handheld body.auth-body select,
    body.auth-body input,
    body.auth-body textarea,
    body.auth-body select {
        width: 100% !important;
        max-width: 100% !important;
        padding: 9px 10px !important;
        font-size: 0.9rem !important;
    }

    html.is-handheld body.auth-body .auth-password-wrap input,
    body.auth-body .auth-password-wrap input {
        padding-right: 62px !important;
    }

    html.is-handheld body.auth-body .auth-password-toggle,
    body.auth-body .auth-password-toggle {
        right: 6px !important;
        font-size: 0.64rem !important;
        padding: 4px 8px !important;
    }

    html.is-handheld body.auth-body .primary-btn,
    html.is-handheld body.auth-body .secondary-btn,
    body.auth-body .primary-btn,
    body.auth-body .secondary-btn {
        min-height: 38px !important;
        padding: 8px 12px !important;
        font-size: 0.8rem !important;
    }

    html.is-handheld body.messages-page.conversation-open.is-authenticated .messages-list,
    html.is-handheld body.messages-page.conversation-open.is-authenticated .messages-list.messages-list-live,
    body.messages-page.conversation-open.is-authenticated .messages-list,
    body.messages-page.conversation-open.is-authenticated .messages-list.messages-list-live {
        align-content: start !important;
        justify-content: start !important;
        align-items: start !important;
        grid-auto-rows: min-content !important;
    }

    html.is-handheld body.messages-page.conversation-open.is-authenticated .bubble,
    body.messages-page.conversation-open.is-authenticated .bubble {
        align-self: start !important;
        height: auto !important;
        max-height: none !important;
    }

    html.is-handheld body.messages-page .bubble-head strong,
    body.messages-page .bubble-head strong {
        display: inline-flex !important;
    }
}

@media (max-width: 520px) {
    html.is-handheld body.auth-body .auth-card h2,
    body.auth-body .auth-card h2 {
        font-size: 1.7rem !important;
    }

    html.is-handheld body.auth-body .top-nav > a,
    html.is-handheld body.auth-body .top-nav button,
    body.auth-body .top-nav > a,
    body.auth-body .top-nav button {
        font-size: 0.74rem !important;
        padding: 5px 8px !important;
    }
}

/* Messages list balanced mobile size (final) */
@media (max-width: 900px) {
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contacts-list,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contacts-list {
        padding: 4px !important;
        gap: 5px !important;
        align-content: start !important;
        grid-auto-rows: min-content !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item,
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link {
        display: grid !important;
        grid-template-columns: 30px minmax(0, 1fr) auto !important;
        align-items: center !important;
        min-height: 52px !important;
        padding: 6px 8px !important;
        gap: 8px !important;
        border-radius: 10px !important;
        height: auto !important;
        max-height: none !important;
        align-self: start !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item .avatar,
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link .avatar,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item .avatar,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link .avatar {
        width: 30px !important;
        height: 30px !important;
        font-size: 0.72rem !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta-top,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta-top {
        gap: 6px !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta-top strong,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta-top strong {
        font-size: 0.86rem !important;
        line-height: 1.15 !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-time,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-time {
        font-size: 0.66rem !important;
        line-height: 1 !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta p,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta p {
        margin: 2px 0 0 !important;
        font-size: 0.76rem !important;
        line-height: 1.2 !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 1 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item .badge,
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link .badge,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item .badge,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link .badge {
        min-width: 14px !important;
        height: 14px !important;
        font-size: 0.58rem !important;
        line-height: 14px !important;
        padding: 0 3px !important;
    }
}

@media (max-width: 520px) {
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item,
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link {
        grid-template-columns: 28px minmax(0, 1fr) auto !important;
        min-height: 48px !important;
        padding: 5px 7px !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item .avatar,
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link .avatar,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item .avatar,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link .avatar {
        width: 28px !important;
        height: 28px !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta-top strong,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta-top strong {
        font-size: 0.82rem !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta p,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta p {
        font-size: 0.74rem !important;
    }
}

body.theme-dark .resources-doc-filters input[type="search"] {
    background: rgba(18, 39, 57, 0.9);
    border-color: rgba(127, 165, 198, 0.34);
    color: #e8f3ff;
}

body.theme-dark .resources-doc-filters input[type="search"]::placeholder {
    color: #93b8d6;
}

body.theme-dark .resource-doc-head h5 {
    color: #e9f4ff;
}

body.theme-dark .resource-scope-pill {
    background: rgba(147, 84, 39, 0.45);
    border-color: rgba(255, 171, 110, 0.5);
    color: #ffd9be;
}

body.theme-dark .resource-subject-pill {
    background: rgba(42, 110, 61, 0.4);
    border-color: rgba(130, 214, 150, 0.45);
    color: #d9ffe1;
}

body.theme-dark .resource-session-pill {
    background: rgba(34, 84, 125, 0.45);
    border-color: rgba(126, 187, 235, 0.5);
    color: #d8efff;
}

body.theme-dark .resource-correction-pill {
    background: rgba(42, 110, 61, 0.4);
    border-color: rgba(130, 214, 150, 0.45);
    color: #d9ffe1;
}

body.theme-dark .resource-missing-pill {
    background: rgba(136, 54, 54, 0.38);
    border-color: rgba(246, 151, 151, 0.45);
    color: #ffdede;
}

body.theme-dark .resource-allo-subject {
    background: rgba(16, 36, 53, 0.9);
    border-color: rgba(122, 164, 199, 0.34);
}

body.theme-dark .resource-allo-year-block {
    background: rgba(20, 43, 63, 0.9);
    border-color: rgba(122, 164, 199, 0.3);
}

body.theme-dark .resource-allo-subject-head h5,
body.theme-dark .resource-allo-year-head h6 {
    color: #e3f1ff;
}


body.theme-dark .resources-pdf-viewer {
    background: rgba(5, 12, 19, 0.97);
}

body.theme-dark .resources-pdf-viewer-head {
    background: rgba(18, 39, 57, 0.92);
    border-color: rgba(127, 165, 198, 0.34);
}

body.theme-dark #resources-pdf-frame {
    background: rgba(18, 39, 57, 0.88);
    border-color: rgba(127, 165, 198, 0.34);
    color: var(--text);
}

body.theme-dark .resources-pdf-viewer-head h5 {
    color: #e9f4ff;
}

/* Conversation readability pass: remove emoji suggestion clutter and maximize message viewport */
body.messages-page .chat-layout.has-active-chat .chat-main.chat-main-live {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

body.messages-page .chat-layout.has-active-chat .chat-header.chat-header-live {
    padding: 7px 10px !important;
    gap: 8px;
}

body.messages-page .chat-layout.has-active-chat .chat-header-user .avatar {
    width: 34px;
    height: 34px;
}

body.messages-page .chat-layout.has-active-chat .chat-status {
    display: none;
}

body.messages-page .chat-layout.has-active-chat .messages-list.messages-list-live {
    flex: 1 1 auto;
    min-height: 0;
    padding: 10px 12px 8px !important;
    gap: 10px;
}

body.messages-page .chat-layout.has-active-chat .bubble {
    max-width: 90%;
    padding: 10px 12px;
}

body.messages-page .chat-layout.has-active-chat .bubble p {
    font-size: 1rem;
    line-height: 1.5;
    margin: 0.28rem 0 0;
}

body.messages-page .chat-layout.has-active-chat .chat-form.chat-form-live {
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom)) !important;
}

body.messages-page .chat-layout.has-active-chat #message-text {
    min-height: 40px;
    max-height: 92px;
    font-size: 0.98rem;
    line-height: 1.42;
}

body.messages-page .chat-layout.has-active-chat .chat-composer-row {
    gap: 6px;
}

body.messages-page .chat-layout.has-active-chat .chat-composer-row .icon-btn {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
}

body.messages-page .chat-layout.has-active-chat .chat-local-status:empty,
body.messages-page .chat-layout.has-active-chat #message-file-name:empty,
body.messages-page .chat-layout.has-active-chat #voice-status:empty {
    display: none;
}

@media (max-width: 900px) {
    body.messages-page.conversation-open.is-authenticated .chat-header.chat-header-live {
        padding: 6px 8px !important;
        min-height: 48px;
    }

    body.messages-page.conversation-open.is-authenticated .chat-header h2 {
        font-size: 0.9rem;
    }

    body.messages-page.conversation-open.is-authenticated .messages-list.messages-list-live {
        padding: 8px 10px 6px !important;
        gap: 9px;
    }

    body.messages-page.conversation-open.is-authenticated .chat-form.chat-form-live {
        padding: 5px 7px calc(7px + env(safe-area-inset-bottom)) !important;
    }

    body.messages-page.conversation-open.is-authenticated #message-text {
        min-height: 38px;
        max-height: 84px;
    }
}

/* Conversations: Zerino moving particles background */
body.messages-page .chat-main.chat-main-live {
    position: relative;
    overflow: hidden;
    isolation: isolate;
}

body.messages-page .chat-particles {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.66;
    mix-blend-mode: screen;
}

body.theme-dark.messages-page .chat-particles {
    opacity: 0.72;
}

body.messages-page .chat-main.chat-main-live > .chat-header,
body.messages-page .chat-main.chat-main-live > .messages-list,
body.messages-page .chat-main.chat-main-live > .bot-helper-card,
body.messages-page .chat-main.chat-main-live > .chat-form,
body.messages-page .chat-main.chat-main-live > .call-overlay {
    position: relative;
    z-index: 1;
}

body.messages-page .chat-layout.has-active-chat .chat-main.chat-main-live,
body.messages-page.conversation-open.is-authenticated .chat-main.chat-main-live {
    background:
        radial-gradient(circle at 16% 10%, rgba(124, 198, 255, 0.14), transparent 58%),
        radial-gradient(circle at 92% 0%, rgba(117, 216, 184, 0.13), transparent 48%),
        linear-gradient(180deg, rgba(242, 249, 255, 0.78), rgba(233, 243, 251, 0.72)) !important;
    backdrop-filter: blur(4px);
}

body.messages-page .chat-layout.has-active-chat .messages-list.messages-list-live,
body.messages-page.conversation-open.is-authenticated .messages-list.messages-list-live {
    background: linear-gradient(180deg, rgba(237, 247, 255, 0.34), rgba(228, 240, 251, 0.2)) !important;
}

body.messages-page .chat-layout.has-active-chat .chat-header.chat-header-live,
body.messages-page .chat-layout.has-active-chat .chat-form.chat-form-live,
body.messages-page.conversation-open.is-authenticated .chat-header.chat-header-live,
body.messages-page.conversation-open.is-authenticated .chat-form.chat-form-live {
    background: linear-gradient(180deg, rgba(247, 252, 255, 0.74), rgba(237, 247, 255, 0.66)) !important;
}

body.theme-dark.messages-page .chat-layout.has-active-chat .chat-main.chat-main-live,
body.theme-dark.messages-page.conversation-open.is-authenticated .chat-main.chat-main-live {
    background:
        radial-gradient(circle at 16% 10%, rgba(90, 164, 219, 0.18), transparent 60%),
        radial-gradient(circle at 92% 0%, rgba(69, 150, 126, 0.16), transparent 50%),
        linear-gradient(180deg, rgba(13, 30, 45, 0.74), rgba(9, 23, 35, 0.72)) !important;
}

body.theme-dark.messages-page .chat-layout.has-active-chat .messages-list.messages-list-live,
body.theme-dark.messages-page.conversation-open.is-authenticated .messages-list.messages-list-live {
    background: linear-gradient(180deg, rgba(10, 24, 36, 0.34), rgba(8, 20, 30, 0.2)) !important;
}

body.theme-dark.messages-page .chat-layout.has-active-chat .chat-header.chat-header-live,
body.theme-dark.messages-page .chat-layout.has-active-chat .chat-form.chat-form-live,
body.theme-dark.messages-page.conversation-open.is-authenticated .chat-header.chat-header-live,
body.theme-dark.messages-page.conversation-open.is-authenticated .chat-form.chat-form-live {
    background: linear-gradient(180deg, rgba(18, 40, 58, 0.74), rgba(13, 31, 46, 0.68)) !important;
}

/* Mobile Stabilization Layer (March 2026) */
@media (max-width: 900px) {
    html,
    body {
        max-width: 100%;
        overflow-x: hidden;
    }

    body.is-authenticated .topbar-inner {
        min-height: 54px;
        padding: 9px 10px;
        gap: 8px;
    }

    body.is-authenticated .brand {
        min-width: 0;
        max-width: 46vw;
    }

    body.is-authenticated .brand-text {
        font-size: 0.94rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    body.is-authenticated .page-shell {
        width: 100%;
        max-width: 100%;
        margin: 8px auto 0 !important;
        padding: 0 8px calc(88px + env(safe-area-inset-bottom)) !important;
    }

    body.is-authenticated .card {
        border-radius: 16px;
    }

    body.dashboard-page .layout-grid {
        grid-template-columns: 1fr !important;
        gap: 10px;
    }

    body.dashboard-page .layout-grid > * {
        min-width: 0;
    }

    body.dashboard-page .layout-grid > .feed-column {
        order: 1;
    }

    body.dashboard-page .layout-grid > .left-rail {
        order: 2;
    }

    body.dashboard-page .layout-grid > .right-rail {
        order: 3;
    }

    body.dashboard-page .left-rail,
    body.dashboard-page .right-rail {
        padding: 12px !important;
        gap: 12px;
    }

    body.dashboard-page .profile-card p {
        font-size: 0.83rem;
        line-height: 1.45;
    }

    body.dashboard-page .quick-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    body.dashboard-page .publish-launch-card {
        padding: 10px;
    }

    body.dashboard-page .stories-bar-card {
        padding: 10px 8px;
    }

    body.dashboard-page .stories-scroll {
        gap: 10px;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
    }

    body.dashboard-page .story-slot {
        scroll-snap-align: start;
    }

    body.dashboard-page .post-card,
    body.search-page .post-card {
        padding: 12px !important;
    }

    body.dashboard-page .post-head,
    body.search-page .post-head {
        align-items: flex-start;
    }

    body.dashboard-page .post-head-right,
    body.search-page .post-head-right {
        flex-direction: column;
        align-items: flex-end;
        gap: 3px;
    }

    body.dashboard-page .post-content,
    body.search-page .post-content {
        font-size: 0.95rem;
        line-height: 1.45;
    }

    body.dashboard-page .post-image,
    body.search-page .post-image {
        max-height: min(66vh, 420px);
    }

    body.dashboard-page .post-actions,
    body.search-page .post-actions {
        justify-content: space-between;
        gap: 6px;
    }

    body.dashboard-page .post-actions .icon-btn,
    body.search-page .post-actions .icon-btn {
        width: 38px;
        height: 38px;
        flex: 0 0 38px;
    }

    body.dashboard-page .post-actions .post-action-btn,
    body.search-page .post-actions .post-action-btn {
        padding: 5px 8px;
        font-size: 0.78rem;
    }

    body.dashboard-page .post-action-btn svg,
    body.search-page .post-action-btn svg {
        width: 17px;
        height: 17px;
    }

    body.dashboard-page .comments-section,
    body.search-page .comments-section {
        gap: 8px;
    }

    body.messages-page.is-authenticated .page-shell {
        margin: 8px auto 0 !important;
        padding: 0 8px calc(92px + env(safe-area-inset-bottom)) !important;
    }

    body.messages-page.is-authenticated .chat-layout {
        grid-template-columns: 1fr !important;
        gap: 10px;
        min-height: calc(100dvh - 150px);
        max-height: none;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .chat-main {
        display: none !important;
    }

    body.messages-page.is-authenticated .chat-layout.has-active-chat .chat-sidebar {
        display: none !important;
    }

    body.messages-page.is-authenticated .chat-sidebar {
        max-height: none !important;
        min-height: calc(100dvh - 212px);
        padding: 0 !important;
    }

    body.messages-page.is-authenticated .chat-sidebar-head {
        position: sticky;
        top: 0;
        z-index: 3;
    }

    body.messages-page.is-authenticated .contact-item {
        border-radius: 12px;
        padding: 9px;
    }

    body.messages-page.conversation-open.is-authenticated .topbar,
    body.messages-page.conversation-open.is-authenticated .footer,
    body.messages-page.conversation-open.is-authenticated .mobile-tabbar {
        display: none !important;
    }

    body.messages-page.conversation-open.is-authenticated .page-shell {
        margin: 0 !important;
        padding: 0 !important;
        max-width: 100% !important;
    }

    body.messages-page.conversation-open.is-authenticated .chat-layout {
        gap: 0 !important;
        min-height: 100dvh !important;
        max-height: 100dvh !important;
    }

    body.messages-page.conversation-open.is-authenticated .chat-main.chat-main-live {
        border: none !important;
        border-radius: 0 !important;
        min-height: 100dvh !important;
        display: grid;
        grid-template-rows: auto minmax(0, 1fr) auto;
    }

    body.messages-page.conversation-open.is-authenticated .chat-header.chat-header-live {
        position: sticky;
        top: 0;
        z-index: 6;
        min-height: 52px;
        padding: 8px 10px !important;
        border-left: none !important;
        border-right: none !important;
        border-top: none !important;
        border-radius: 0 !important;
    }

    body.messages-page.conversation-open.is-authenticated .chat-header h2 {
        font-size: 0.96rem !important;
    }

    body.messages-page.conversation-open.is-authenticated .messages-list.messages-list-live {
        padding: 10px 10px 12px !important;
        gap: 10px;
        overscroll-behavior: contain;
    }

    body.messages-page.conversation-open.is-authenticated .bubble {
        max-width: 92%;
    }

    body.messages-page.conversation-open.is-authenticated .chat-form.chat-form-live {
        position: sticky;
        bottom: 0;
        z-index: 7;
        border-left: none !important;
        border-right: none !important;
        border-bottom: none !important;
        border-radius: 0 !important;
        padding: 8px 8px calc(8px + env(safe-area-inset-bottom)) !important;
    }

    body.messages-page.conversation-open.is-authenticated #message-text {
        min-height: 46px !important;
        max-height: 120px !important;
        font-size: 1rem;
    }

    body.messages-page.conversation-open.is-authenticated .chat-composer-row .icon-btn {
        width: 38px;
        height: 38px;
        flex: 0 0 38px;
    }

    body.messages-page.conversation-open.is-authenticated .bot-helper-card-bottom {
        margin: 0 8px 6px;
        border-radius: 12px;
    }

    body.profile-page.is-authenticated .profile-ig-wrap {
        padding: 12px 8px !important;
        border-radius: 16px;
    }

    body.profile-page.is-authenticated .ig-profile-header {
        grid-template-columns: 78px minmax(0, 1fr) !important;
        gap: 10px !important;
        align-items: start;
        padding-bottom: 12px;
    }

    body.profile-page.is-authenticated .ig-avatar-wrap,
    body.profile-page.is-authenticated .ig-avatar-shell {
        width: 78px !important;
        height: 78px !important;
    }

    body.profile-page.is-authenticated .ig-avatar {
        width: 70px !important;
        height: 70px !important;
        border-width: 2px !important;
        font-size: 1.25rem !important;
    }

    body.profile-page.is-authenticated .ig-top-row {
        gap: 6px;
    }

    body.profile-page.is-authenticated .ig-username {
        font-size: 1.02rem !important;
        margin-right: 4px;
    }

    body.profile-page.is-authenticated .ig-stat-line {
        gap: 12px !important;
        font-size: 0.86rem;
    }

    body.profile-page.is-authenticated .ig-bio-block,
    body.profile-page.is-authenticated .ig-bio-block p,
    body.profile-page.is-authenticated .ig-bio-text {
        text-align: left !important;
    }

    body.profile-page.is-authenticated .student-progress-card {
        padding: 8px 10px;
    }

    body.profile-page.is-authenticated .student-progress-row {
        margin-top: 7px;
    }

    body.profile-page.is-authenticated .student-progress-head {
        gap: 8px;
        align-items: center;
    }

    body.profile-page.is-authenticated .student-progress-track {
        height: 8px !important;
    }

    body.profile-page.is-authenticated .ig-highlights {
        padding: 10px 0 12px;
        gap: 14px;
    }

    body.profile-page.is-authenticated .ig-tabs {
        position: sticky;
        top: 54px;
        z-index: 4;
        background: inherit;
    }

    body.profile-page.is-authenticated .ig-post-grid {
        gap: 3px;
    }

    body.settings-page .settings-modern-shell {
        gap: 10px;
    }

    body.settings-page .settings-menu-card,
    body.settings-page .settings-section-card {
        padding: 12px !important;
        border-radius: 14px;
    }

    body.settings-page .settings-modern-shell.is-section-view .settings-menu-card {
        display: none !important;
    }

    body.settings-page .settings-modern-shell.is-section-view .settings-modern-content {
        display: block !important;
    }

    body.search-page .search-main-form {
        grid-template-columns: 1fr !important;
        gap: 8px;
    }

    body.search-page .search-layout {
        grid-template-columns: 1fr !important;
        gap: 10px;
    }

    body.publish-page .center-wrap {
        padding: 0;
    }

    body.publish-page .publish-card,
    body.notifications-screen .notifications-page {
        padding: 14px !important;
    }

    body.resources-screen .resources-page,
    body.courses-page .resources-page {
        padding: 12px !important;
    }

    body.resources-screen .resources-grid,
    body.courses-page .resources-grid,
    body.resources-screen .resources-grid-split,
    body.courses-page .resources-grid-split {
        grid-template-columns: 1fr !important;
        gap: 10px;
    }

    body.resources-screen .resources-country-row,
    body.resources-screen .resources-doc-filters,
    body.courses-page .resources-doc-filters,
    body.resources-screen .curriculum-controls {
        grid-template-columns: 1fr !important;
        gap: 8px;
    }

    body.resources-screen .resource-doc-actions,
    body.courses-page .resource-doc-actions {
        gap: 6px;
    }

    body.resources-screen .resource-doc-actions .mini-btn,
    body.resources-screen .resource-doc-actions .primary-btn,
    body.resources-screen .resource-doc-actions .secondary-btn,
    body.courses-page .resource-doc-actions .mini-btn,
    body.courses-page .resource-doc-actions .primary-btn,
    body.courses-page .resource-doc-actions .secondary-btn {
        flex: 1 1 calc(50% - 6px);
        text-align: center;
    }

    body.resources-screen #resources-pdf-frame {
        height: calc(100dvh - 112px) !important;
    }

    /* Story viewer responsive overrides removed — handled in force-override block */

    body.is-authenticated .mobile-tabbar {
        left: 8px;
        right: 8px;
        bottom: calc(8px + env(safe-area-inset-bottom));
        border-radius: 15px;
        padding: 6px;
        gap: 4px;
    }

    body.is-authenticated .mobile-tab {
        min-height: 48px;
    }

    body.is-authenticated .mobile-tab-icon,
    body.is-authenticated .mobile-tab-avatar,
    body.is-authenticated .mobile-tab-avatar-fallback {
        width: 26px;
        height: 26px;
    }

    body.is-authenticated .mobile-tab-icon-publish {
        width: 30px;
        height: 30px;
    }
}

@media (max-width: 520px) {
    body.dashboard-page .profile-card p,
    body.search-page .suggestion-item p {
        font-size: 0.78rem;
    }

    body.messages-page.conversation-open.is-authenticated .bubble {
        max-width: 94%;
    }

    body.resources-screen .resource-doc-actions .mini-btn,
    body.resources-screen .resource-doc-actions .primary-btn,
    body.resources-screen .resource-doc-actions .secondary-btn,
    body.courses-page .resource-doc-actions .mini-btn,
    body.courses-page .resource-doc-actions .primary-btn,
    body.courses-page .resource-doc-actions .secondary-btn {
        flex-basis: 100%;
    }

    body.is-authenticated .mobile-tabbar {
        left: 6px;
        right: 6px;
    }
}

/* Mobile Compact Fit Layer (March 2026 - no desktop impact) */
@media (max-width: 900px) {
    html,
    body {
        max-width: 100%;
        overflow-x: hidden !important;
    }

    body .page-shell,
    body .page-shell > *,
    body .layout-grid,
    body .layout-grid > *,
    body .search-layout,
    body .search-layout > *,
    body .resources-grid,
    body .resources-grid > *,
    body .chat-layout,
    body .chat-layout > * {
        min-width: 0 !important;
        max-width: 100% !important;
    }

    body.is-authenticated {
        font-size: 14px;
    }

    body.is-authenticated .page-shell {
        padding-left: 6px !important;
        padding-right: 6px !important;
    }

    body.is-authenticated .card {
        border-radius: 14px;
    }

    body.is-authenticated h1 {
        font-size: 1.16rem !important;
        line-height: 1.25;
    }

    body.is-authenticated h2 {
        font-size: 1.01rem !important;
        line-height: 1.25;
    }

    body.is-authenticated h3 {
        font-size: 0.92rem !important;
        line-height: 1.25;
    }

    body.is-authenticated p,
    body.is-authenticated small,
    body.is-authenticated .muted,
    body.is-authenticated label,
    body.is-authenticated input,
    body.is-authenticated select,
    body.is-authenticated textarea {
        font-size: 0.83rem;
    }

    body.is-authenticated input,
    body.is-authenticated select,
    body.is-authenticated textarea {
        padding: 9px 10px;
    }

    body.is-authenticated img,
    body.is-authenticated video,
    body.is-authenticated iframe,
    body.is-authenticated canvas {
        max-width: 100%;
    }

    body.is-authenticated .primary-btn,
    body.is-authenticated .secondary-btn {
        padding: 9px 13px;
        font-size: 0.8rem;
    }

    body.is-authenticated .mini-btn,
    body.is-authenticated .ghost-btn,
    body.is-authenticated .pill-btn {
        padding: 7px 10px;
        font-size: 0.74rem;
    }

    body.is-authenticated .icon-btn {
        width: 34px;
        height: 34px;
    }

    body.dashboard-page .left-rail,
    body.dashboard-page .right-rail {
        padding: 10px !important;
        gap: 10px;
    }

    body.dashboard-page .avatar-big {
        width: 58px;
        height: 58px;
        font-size: 1.12rem;
    }

    body.dashboard-page .profile-icon-btn {
        width: 36px;
        height: 36px;
        font-size: 0.95rem;
    }

    body.dashboard-page .profile-card p {
        line-height: 1.35;
    }

    body.dashboard-page .stats-row {
        gap: 6px;
    }

    body.dashboard-page .stats-row strong {
        font-size: 0.92rem;
    }

    body.dashboard-page .stats-row span {
        font-size: 0.72rem;
    }

    body.dashboard-page .stories-bar-card,
    body.dashboard-page .publish-launch-card,
    body.dashboard-page .post-card,
    body.search-page .post-card {
        padding: 10px !important;
    }

    body.dashboard-page .story-avatar-wrap,
    body.dashboard-page .story-ring {
        width: 58px;
        height: 58px;
    }

    body.dashboard-page .story-slot {
        min-width: 68px;
        max-width: 68px;
    }

    body.dashboard-page .story-plus-badge {
        width: 20px;
        height: 20px;
        font-size: 0.8rem;
    }

    body.dashboard-page .post-head,
    body.search-page .post-head {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: start;
        gap: 6px;
        margin-bottom: 6px;
    }

    body.dashboard-page .user-chip,
    body.search-page .user-chip {
        min-width: 0;
        gap: 6px;
    }

    body.dashboard-page .user-chip .name-with-badge,
    body.search-page .user-chip .name-with-badge {
        min-width: 0;
        max-width: 100%;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    body.dashboard-page .post-head-right,
    body.search-page .post-head-right {
        flex-direction: column;
        align-items: flex-end;
        gap: 3px;
    }

    body.dashboard-page .post-content,
    body.search-page .post-content {
        margin: 8px 0;
        line-height: 1.38;
    }

    body.dashboard-page .post-image,
    body.search-page .post-image {
        border-radius: 10px;
        max-height: min(58vh, 340px);
    }

    body.dashboard-page .post-metrics,
    body.search-page .post-metrics {
        margin-top: 7px;
        gap: 8px;
        font-size: 0.77rem;
    }

    body.dashboard-page .post-actions,
    body.search-page .post-actions {
        margin-top: 6px;
        gap: 5px;
    }

    body.dashboard-page .post-actions .icon-btn,
    body.search-page .post-actions .icon-btn {
        width: 34px;
        height: 34px;
        flex: 0 0 34px;
    }

    body.dashboard-page .post-actions .post-action-btn,
    body.search-page .post-actions .post-action-btn {
        padding: 4px 7px;
        font-size: 0.75rem;
        gap: 4px;
    }

    body.dashboard-page .post-action-btn svg,
    body.search-page .post-action-btn svg {
        width: 16px;
        height: 16px;
    }

    body.dashboard-page .comments-section,
    body.search-page .comments-section {
        margin-top: 8px;
        padding-top: 8px;
        gap: 7px;
    }

    body.dashboard-page .comment-item,
    body.search-page .comment-item {
        gap: 6px;
    }

    body.dashboard-page .comment-item p,
    body.search-page .comment-item p {
        font-size: 0.8rem;
        line-height: 1.32;
    }

    body.dashboard-page .comment-form,
    body.search-page .comment-form {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 6px;
    }

    body.dashboard-page .comment-form input,
    body.search-page .comment-form input {
        min-width: 0;
        padding: 7px 10px;
    }

    body.messages-page .chat-sidebar,
    body.messages-page .chat-main {
        border-radius: 14px !important;
    }

    body.messages-page .chat-sidebar-head {
        padding: 9px !important;
    }

    body.messages-page .chat-sidebar .section-head h2 {
        font-size: 0.95rem !important;
    }

    body.messages-page .contact-item {
        padding: 8px;
        border-radius: 10px;
    }

    body.messages-page .contact-item .avatar {
        width: 32px;
        height: 32px;
    }

    body.messages-page .contact-meta p {
        font-size: 0.78rem;
    }

    body.messages-page.conversation-open.is-authenticated .chat-header.chat-header-live {
        min-height: 48px;
        padding: 7px 8px !important;
    }

    body.messages-page.conversation-open.is-authenticated .chat-header .avatar {
        width: 30px;
        height: 30px;
    }

    body.messages-page.conversation-open.is-authenticated .chat-header h2 {
        font-size: 0.9rem !important;
    }

    body.messages-page.conversation-open.is-authenticated .messages-list.messages-list-live {
        padding: 8px 8px 10px !important;
        gap: 8px;
    }

    body.messages-page.conversation-open.is-authenticated .bubble {
        padding: 8px 10px;
        border-radius: 12px;
        max-width: 90%;
    }

    body.messages-page.conversation-open.is-authenticated .bubble-head {
        font-size: 0.73rem;
    }

    body.messages-page.conversation-open.is-authenticated .bubble p {
        font-size: 0.84rem;
        line-height: 1.34;
    }

    body.messages-page.conversation-open.is-authenticated .chat-form.chat-form-live {
        padding: 6px 6px calc(6px + env(safe-area-inset-bottom)) !important;
    }

    body.messages-page.conversation-open.is-authenticated #message-text {
        min-height: 40px !important;
        max-height: 92px !important;
        font-size: 0.88rem;
        line-height: 1.35;
    }

    body.messages-page.conversation-open.is-authenticated .chat-composer-row .icon-btn {
        width: 34px;
        height: 34px;
        flex: 0 0 34px;
    }

    body.profile-page.is-authenticated .profile-ig-wrap {
        padding: 10px 6px !important;
    }

    body.profile-page.is-authenticated .ig-profile-header {
        grid-template-columns: 68px minmax(0, 1fr) !important;
        gap: 8px !important;
        padding-bottom: 10px;
    }

    body.profile-page.is-authenticated .ig-avatar-wrap,
    body.profile-page.is-authenticated .ig-avatar-shell {
        width: 68px !important;
        height: 68px !important;
    }

    body.profile-page.is-authenticated .ig-avatar {
        width: 62px !important;
        height: 62px !important;
        font-size: 1rem !important;
    }

    body.profile-page.is-authenticated .ig-top-row {
        gap: 5px;
    }

    body.profile-page.is-authenticated .ig-stat-line {
        gap: 8px !important;
        font-size: 0.78rem;
    }

    body.profile-page.is-authenticated .ig-bio-block p,
    body.profile-page.is-authenticated .ig-bio-text,
    body.profile-page.is-authenticated .ig-role-line,
    body.profile-page.is-authenticated .ig-country-line,
    body.profile-page.is-authenticated .ig-email-line {
        font-size: 0.78rem;
        line-height: 1.3;
    }

    body.profile-page.is-authenticated .ig-highlight-ring {
        width: 62px;
        height: 62px;
    }

    body.profile-page.is-authenticated .ig-highlight-item small {
        font-size: 0.68rem;
    }

    body.profile-page.is-authenticated .ig-tab {
        padding: 10px 0;
        font-size: 0.66rem;
        gap: 4px;
    }

    body.profile-page.is-authenticated .student-progress-card {
        padding: 7px 8px;
    }

    body.profile-page.is-authenticated .student-progress-head {
        font-size: 0.75rem;
    }

    body.profile-page.is-authenticated .student-progress-track {
        height: 7px !important;
    }

    body.settings-page .settings-menu-card,
    body.settings-page .settings-section-card,
    body.publish-page .publish-card,
    body.notifications-screen .notifications-page,
    body.resources-screen .resources-page,
    body.courses-page .resources-page,
    body.search-page .search-hero-card {
        padding: 10px !important;
    }

    body.search-page .search-main-form,
    body.resources-screen .resources-country-row,
    body.resources-screen .resources-doc-filters,
    body.resources-screen .curriculum-controls,
    body.courses-page .resources-doc-filters {
        gap: 6px !important;
    }

    body.resources-screen .resource-item,
    body.resources-screen .resource-doc-item,
    body.courses-page .offer-item {
        padding: 8px;
        border-radius: 10px;
    }

    body.resources-screen .resource-doc-actions,
    body.courses-page .resource-doc-actions {
        gap: 5px;
    }

    body.resources-screen .resource-doc-actions .mini-btn,
    body.resources-screen .resource-doc-actions .primary-btn,
    body.resources-screen .resource-doc-actions .secondary-btn,
    body.courses-page .resource-doc-actions .mini-btn,
    body.courses-page .resource-doc-actions .primary-btn,
    body.courses-page .resource-doc-actions .secondary-btn {
        padding: 7px 9px;
        font-size: 0.72rem;
    }

    body.resources-screen #resources-pdf-frame {
        height: calc(100dvh - 106px) !important;
    }

    .story-viewer-meta {
        padding: 8px 10px;
    }

    .story-viewer-actions {
        padding: 8px 10px;
    }

    .story-reply-form {
        padding: 8px 10px 0;
        gap: 6px;
    }

    .story-reply-form input {
        padding: 8px 10px;
    }
}

@media (max-width: 520px) {
    body.is-authenticated {
        font-size: 13px;
    }

    body.dashboard-page .post-head-right .mini-btn,
    body.search-page .post-head-right .mini-btn {
        padding: 6px 8px;
        font-size: 0.68rem;
    }

    body.profile-page.is-authenticated .ig-profile-header {
        grid-template-columns: 62px minmax(0, 1fr) !important;
    }

    body.profile-page.is-authenticated .ig-avatar-wrap,
    body.profile-page.is-authenticated .ig-avatar-shell {
        width: 62px !important;
        height: 62px !important;
    }

    body.profile-page.is-authenticated .ig-avatar {
        width: 56px !important;
        height: 56px !important;
    }
}

/* Messages Mobile Compact Layer (March 2026) */
@media (max-width: 900px) {
    body.messages-page.is-authenticated {
        font-size: 13.5px;
    }

    body.messages-page.is-authenticated .page-shell {
        margin: 6px auto 0 !important;
        padding: 0 4px calc(82px + env(safe-area-inset-bottom)) !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-layout {
        gap: 8px !important;
        min-height: calc(100dvh - 144px) !important;
        max-height: calc(100dvh - 144px) !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-sidebar {
        min-height: 0 !important;
        max-height: none !important;
        border-radius: 12px !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-sidebar-head {
        position: sticky;
        top: 0;
        z-index: 6;
        padding: 8px !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-sidebar-title-row {
        gap: 6px;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-head-actions {
        gap: 5px;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-head-actions .mini-btn,
    body.messages-page.is-authenticated:not(.conversation-open) .chat-head-actions a {
        padding: 6px 8px !important;
        font-size: 0.68rem !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-contact-search-wrap {
        margin-top: 6px;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-contact-search {
        padding: 8px 10px !important;
        font-size: 0.8rem !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contacts-list {
        padding: 7px !important;
        gap: 6px !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-item {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) auto;
        align-items: center;
        gap: 7px;
        padding: 7px !important;
        border-radius: 10px !important;
        min-width: 0;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-item .avatar {
        width: 31px;
        height: 31px;
        font-size: 0.74rem;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-meta {
        min-width: 0;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-meta-top {
        gap: 5px;
        align-items: center;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-meta-top strong {
        font-size: 0.8rem !important;
        min-width: 0;
        max-width: 100%;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-time {
        font-size: 0.64rem !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-meta p {
        margin-top: 1px;
        font-size: 0.72rem !important;
        line-height: 1.28;
        display: -webkit-box;
        -webkit-line-clamp: 1;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-item .badge {
        min-width: 16px;
        height: 16px;
        font-size: 0.62rem;
        padding: 0 4px;
        line-height: 16px;
    }

    body.messages-page.conversation-open.is-authenticated .topbar,
    body.messages-page.conversation-open.is-authenticated .footer,
    body.messages-page.conversation-open.is-authenticated .mobile-tabbar {
        display: none !important;
    }

    body.messages-page.conversation-open.is-authenticated .page-shell {
        margin: 0 !important;
        padding: 0 !important;
        max-width: 100% !important;
    }

    body.messages-page.conversation-open.is-authenticated .chat-layout {
        gap: 0 !important;
        min-height: 100dvh !important;
        max-height: 100dvh !important;
    }

    body.messages-page.conversation-open.is-authenticated .chat-main.chat-main-live {
        border-radius: 0 !important;
        border: none !important;
        min-height: 100dvh !important;
        max-height: 100dvh !important;
        display: grid;
        grid-template-rows: auto minmax(0, 1fr) auto;
    }

    body.messages-page.conversation-open.is-authenticated .chat-header.chat-header-live {
        position: sticky;
        top: 0;
        z-index: 8;
        min-height: 46px !important;
        padding: 6px 8px !important;
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
        border-top: none !important;
        gap: 6px;
    }

    body.messages-page.conversation-open.is-authenticated .chat-mobile-back {
        width: 28px;
        height: 28px;
    }

    body.messages-page.conversation-open.is-authenticated .chat-header-user {
        gap: 6px;
        min-width: 0;
    }

    body.messages-page.conversation-open.is-authenticated .chat-header .avatar {
        width: 28px;
        height: 28px;
    }

    body.messages-page.conversation-open.is-authenticated .chat-header h2 {
        font-size: 0.84rem !important;
        line-height: 1.2;
    }

    body.messages-page.conversation-open.is-authenticated .chat-status {
        font-size: 0.64rem !important;
    }

    body.messages-page.conversation-open.is-authenticated .chat-call-actions {
        gap: 4px;
        margin-right: 0;
    }

    body.messages-page.conversation-open.is-authenticated .chat-call-actions .icon-btn {
        width: 30px;
        height: 30px;
        flex: 0 0 30px;
    }

    body.messages-page.conversation-open.is-authenticated .chat-header-follow {
        display: none !important;
    }

    body.messages-page.conversation-open.is-authenticated .messages-list.messages-list-live {
        padding: 7px 7px 9px !important;
        gap: 7px !important;
    }

    body.messages-page.conversation-open.is-authenticated .bubble {
        max-width: 88% !important;
        padding: 7px 9px !important;
        border-radius: 11px !important;
    }

    body.messages-page.conversation-open.is-authenticated .bubble-head {
        font-size: 0.7rem !important;
        gap: 6px;
    }

    body.messages-page.conversation-open.is-authenticated .bubble-head strong {
        font-size: 0.72rem !important;
    }

    body.messages-page.conversation-open.is-authenticated .bubble-head small {
        font-size: 0.62rem !important;
    }

    body.messages-page.conversation-open.is-authenticated .bubble p {
        margin-top: 2px;
        font-size: 0.8rem !important;
        line-height: 1.3 !important;
    }

    body.messages-page.conversation-open.is-authenticated .reaction-strip {
        gap: 4px;
    }

    body.messages-page.conversation-open.is-authenticated .reaction-chip {
        padding: 3px 6px;
        border-radius: 999px;
        font-size: 0.66rem;
    }

    body.messages-page.conversation-open.is-authenticated .shared-post-card,
    body.messages-page.conversation-open.is-authenticated .bot-helper-card,
    body.messages-page.conversation-open.is-authenticated .bot-helper-card-bottom {
        border-radius: 10px !important;
        padding: 7px !important;
    }

    body.messages-page.conversation-open.is-authenticated .shared-post-text {
        font-size: 0.76rem;
        line-height: 1.28;
    }

    body.messages-page.conversation-open.is-authenticated .shared-post-image {
        max-height: 190px;
        border-radius: 8px;
    }

    body.messages-page.conversation-open.is-authenticated .audio-message {
        width: 100%;
        max-width: 100%;
        height: 30px;
    }

    body.messages-page.conversation-open.is-authenticated .chat-form.chat-form-live {
        position: sticky;
        bottom: 0;
        z-index: 9;
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
        border-bottom: none !important;
        padding: 5px 6px calc(5px + env(safe-area-inset-bottom)) !important;
    }

    body.messages-page.conversation-open.is-authenticated #message-text {
        min-height: 36px !important;
        max-height: 82px !important;
        font-size: 0.84rem !important;
        line-height: 1.3 !important;
        padding: 8px 9px !important;
    }

    body.messages-page.conversation-open.is-authenticated .chat-composer-row {
        gap: 4px !important;
    }

    body.messages-page.conversation-open.is-authenticated .chat-composer-row .icon-btn {
        width: 32px !important;
        height: 32px !important;
        flex: 0 0 32px !important;
    }

    body.messages-page.conversation-open.is-authenticated .chat-composer-row .icon-btn svg {
        width: 15px;
        height: 15px;
    }

    body.messages-page.conversation-open.is-authenticated .chat-local-status,
    body.messages-page.conversation-open.is-authenticated #message-file-name,
    body.messages-page.conversation-open.is-authenticated #voice-status {
        font-size: 0.64rem;
        line-height: 1.2;
    }

    body.messages-page.conversation-open.is-authenticated .bot-prompt-row-compact {
        gap: 4px;
    }

    body.messages-page.conversation-open.is-authenticated .bot-prompt-btn {
        padding: 4px 7px;
        font-size: 0.64rem;
    }
}

@media (max-width: 520px) {
    body.messages-page.is-authenticated {
        font-size: 13px;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-item {
        grid-template-columns: auto minmax(0, 1fr);
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-item .badge {
        grid-column: 2;
        justify-self: end;
    }

    body.messages-page.conversation-open.is-authenticated .chat-header.chat-header-live {
        min-height: 44px !important;
        padding: 5px 7px !important;
    }

    body.messages-page.conversation-open.is-authenticated .chat-header h2 {
        font-size: 0.8rem !important;
    }

    body.messages-page.conversation-open.is-authenticated .bubble {
        max-width: 90% !important;
    }

    body.messages-page.conversation-open.is-authenticated .bubble p {
        font-size: 0.78rem !important;
    }

    body.messages-page.conversation-open.is-authenticated #message-text {
        font-size: 0.8rem !important;
    }
}

/* Messages Mobile Hotfix (fit + no horizontal swipe) */
@media (max-width: 900px) {
    body.messages-page,
    body.messages-page .page-shell,
    body.messages-page .chat-layout,
    body.messages-page .chat-sidebar,
    body.messages-page .chat-main,
    body.messages-page .contacts-list,
    body.messages-page .contact-item,
    body.messages-page .contact-meta,
    body.messages-page .messages-list,
    body.messages-page .bubble,
    body.messages-page .chat-form {
        max-width: 100vw !important;
        min-width: 0 !important;
        overflow-x: hidden !important;
        box-sizing: border-box;
    }

    body.messages-page .bubble p,
    body.messages-page .shared-post-text,
    body.messages-page .attachment-link {
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .page-shell {
        padding-left: 3px !important;
        padding-right: 3px !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contacts-list {
        padding: 5px !important;
        gap: 5px !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-item {
        padding: 6px !important;
        border-radius: 9px !important;
        gap: 6px !important;
        min-height: 50px !important;
        grid-template-columns: 26px minmax(0, 1fr) auto !important;
        align-items: center !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-item .avatar {
        width: 26px !important;
        height: 26px !important;
        font-size: 0.66rem !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-meta-top strong {
        font-size: 0.75rem !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-time {
        font-size: 0.6rem !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-meta p {
        font-size: 0.68rem !important;
        line-height: 1.24 !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-item .badge {
        min-width: 14px !important;
        height: 14px !important;
        font-size: 0.56rem !important;
        line-height: 14px !important;
        padding: 0 3px !important;
    }

    body.messages-page.conversation-open.is-authenticated .topbar,
    body.messages-page.conversation-open.is-authenticated .footer,
    body.messages-page.conversation-open.is-authenticated .mobile-tabbar {
        display: none !important;
    }

    body.messages-page.conversation-open.is-authenticated,
    body.messages-page.conversation-open.is-authenticated .page-shell {
        overflow: hidden !important;
    }

    body.messages-page.conversation-open.is-authenticated .page-shell {
        margin: 0 !important;
        padding: 0 !important;
        width: 100vw !important;
        max-width: 100vw !important;
    }

    body.messages-page.conversation-open.is-authenticated .chat-layout {
        width: 100vw !important;
        max-width: 100vw !important;
        min-height: 100dvh !important;
        max-height: 100dvh !important;
        gap: 0 !important;
    }

    body.messages-page.conversation-open.is-authenticated .chat-sidebar {
        display: none !important;
    }

    body.messages-page.conversation-open.is-authenticated .chat-main,
    body.messages-page.conversation-open.is-authenticated .chat-main.chat-main-live {
        width: 100vw !important;
        max-width: 100vw !important;
        min-height: 100dvh !important;
        max-height: 100dvh !important;
        border: none !important;
        border-radius: 0 !important;
        display: grid !important;
        grid-template-rows: auto minmax(0, 1fr) auto !important;
    }

    body.messages-page.conversation-open.is-authenticated .chat-header,
    body.messages-page.conversation-open.is-authenticated .chat-header.chat-header-live {
        width: 100% !important;
        min-height: 42px !important;
        padding: 4px 6px !important;
        gap: 5px !important;
    }

    body.messages-page.conversation-open.is-authenticated .chat-mobile-back {
        width: 24px !important;
        height: 24px !important;
    }

    body.messages-page.conversation-open.is-authenticated .chat-header .avatar {
        width: 24px !important;
        height: 24px !important;
    }

    body.messages-page.conversation-open.is-authenticated .chat-header h2 {
        font-size: 0.76rem !important;
        line-height: 1.15 !important;
        max-width: 44vw !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    body.messages-page.conversation-open.is-authenticated .chat-status {
        font-size: 0.58rem !important;
    }

    body.messages-page.conversation-open.is-authenticated .chat-call-actions {
        display: none !important;
    }

    body.messages-page.conversation-open.is-authenticated .messages-list,
    body.messages-page.conversation-open.is-authenticated .messages-list.messages-list-live {
        width: 100% !important;
        padding: 6px 5px 8px !important;
        gap: 6px !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
    }

    body.messages-page.conversation-open.is-authenticated .bubble {
        max-width: 84% !important;
        padding: 6px 8px !important;
        border-radius: 10px !important;
    }

    body.messages-page.conversation-open.is-authenticated .bubble-head {
        font-size: 0.64rem !important;
    }

    body.messages-page.conversation-open.is-authenticated .bubble p {
        font-size: 0.74rem !important;
        line-height: 1.24 !important;
    }

    body.messages-page.conversation-open.is-authenticated .chat-form,
    body.messages-page.conversation-open.is-authenticated .chat-form.chat-form-live {
        width: 100% !important;
        padding: 4px 5px calc(4px + env(safe-area-inset-bottom)) !important;
        border-left: none !important;
        border-right: none !important;
        border-bottom: none !important;
    }

    body.messages-page.conversation-open.is-authenticated #message-text {
        min-height: 34px !important;
        max-height: 70px !important;
        font-size: 0.76rem !important;
        line-height: 1.22 !important;
        padding: 7px 8px !important;
    }

    body.messages-page.conversation-open.is-authenticated .chat-composer-row {
        gap: 3px !important;
    }

    body.messages-page.conversation-open.is-authenticated .chat-composer-row .icon-btn {
        width: 28px !important;
        height: 28px !important;
        flex: 0 0 28px !important;
    }
}

@media (max-width: 520px) {
    body.messages-page.is-authenticated:not(.conversation-open) .contact-item {
        grid-template-columns: 24px minmax(0, 1fr) auto !important;
        min-height: 46px !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-item .avatar {
        width: 24px !important;
        height: 24px !important;
    }

    body.messages-page.conversation-open.is-authenticated .chat-header h2 {
        max-width: 40vw !important;
    }

    body.messages-page.conversation-open.is-authenticated .bubble {
        max-width: 86% !important;
    }
}

/* Messages list fit guarantee (mobile): show at least 3 rows directly */
@media (max-width: 900px) {
    body.messages-page.is-authenticated:not(.conversation-open) .page-shell {
        margin: 4px auto 0 !important;
        padding: 0 3px calc(80px + env(safe-area-inset-bottom)) !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-layout {
        grid-template-columns: 1fr !important;
        gap: 0 !important;
        min-height: calc(100dvh - 132px) !important;
        max-height: calc(100dvh - 132px) !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-main {
        display: none !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-sidebar {
        display: grid !important;
        grid-template-rows: auto minmax(0, 1fr) !important;
        min-height: calc(100dvh - 132px) !important;
        max-height: calc(100dvh - 132px) !important;
        overflow: hidden !important;
        border-radius: 10px !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-sidebar-head {
        padding: 5px 6px !important;
        position: sticky;
        top: 0;
        z-index: 5;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-sidebar-title-row {
        gap: 4px !important;
        align-items: center !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-sidebar-title-row h2 {
        font-size: 0.82rem !important;
        line-height: 1.1 !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-subtitle {
        display: none !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-head-actions {
        gap: 3px !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-head-actions a {
        padding: 4px 6px !important;
        font-size: 0.6rem !important;
        border-radius: 999px !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-contact-search-wrap {
        margin-top: 4px !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-contact-search-wrap label {
        display: none !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-contact-search {
        height: 28px !important;
        padding: 5px 8px !important;
        font-size: 0.72rem !important;
        border-radius: 8px !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contacts-list {
        min-height: 0 !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        padding: 3px !important;
        gap: 3px !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-item,
    body.messages-page.is-authenticated:not(.conversation-open) .contact-row-link {
        grid-template-columns: 20px minmax(0, 1fr) auto !important;
        align-items: center !important;
        min-height: 34px !important;
        padding: 3px 5px !important;
        gap: 4px !important;
        border-radius: 7px !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-item .avatar {
        width: 20px !important;
        height: 20px !important;
        font-size: 0.54rem !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-meta-top strong {
        font-size: 0.66rem !important;
        line-height: 1.05 !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-time {
        font-size: 0.5rem !important;
        line-height: 1 !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-meta > small.muted {
        display: none !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-meta p {
        margin: 0 !important;
        font-size: 0.58rem !important;
        line-height: 1.05 !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 1 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
    }
}

@media (max-width: 520px) {
    body.messages-page.is-authenticated:not(.conversation-open) .chat-layout,
    body.messages-page.is-authenticated:not(.conversation-open) .chat-sidebar {
        min-height: calc(100dvh - 126px) !important;
        max-height: calc(100dvh - 126px) !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-item,
    body.messages-page.is-authenticated:not(.conversation-open) .contact-row-link {
        grid-template-columns: 18px minmax(0, 1fr) auto !important;
        min-height: 30px !important;
        padding: 2px 4px !important;
        gap: 3px !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-item .avatar {
        width: 18px !important;
        height: 18px !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-meta p {
        font-size: 0.54rem !important;
        line-height: 1.02 !important;
    }
}

/* Messages list ultra-compact (mobile only) */
@media (max-width: 900px) {
    body.messages-page.is-authenticated:not(.conversation-open) .contacts-list {
        padding: 3px !important;
        gap: 3px !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-item,
    body.messages-page.is-authenticated:not(.conversation-open) .contact-row-link {
        grid-template-columns: 20px minmax(0, 1fr) auto !important;
        align-items: center !important;
        gap: 4px !important;
        padding: 3px 5px !important;
        min-height: 34px !important;
        border-radius: 7px !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-item .avatar {
        width: 20px !important;
        height: 20px !important;
        font-size: 0.54rem !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-meta {
        min-width: 0 !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-meta-top {
        gap: 3px !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-meta-top strong {
        font-size: 0.66rem !important;
        line-height: 1.05 !important;
        min-width: 0;
        max-width: 100%;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-time {
        font-size: 0.52rem !important;
        line-height: 1 !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-meta > small.muted {
        display: none !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-meta p {
        margin: 0 !important;
        font-size: 0.58rem !important;
        line-height: 1.06 !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 1 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .bot-chip {
        padding: 1px 4px !important;
        font-size: 0.52rem !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-item .badge {
        min-width: 11px !important;
        height: 11px !important;
        padding: 0 2px !important;
        font-size: 0.48rem !important;
        line-height: 11px !important;
    }
}

@media (max-width: 520px) {
    body.messages-page.is-authenticated:not(.conversation-open) .contact-item,
    body.messages-page.is-authenticated:not(.conversation-open) .contact-row-link {
        grid-template-columns: 18px minmax(0, 1fr) auto !important;
        min-height: 30px !important;
        padding: 2px 4px !important;
        gap: 3px !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-item .avatar {
        width: 18px !important;
        height: 18px !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-meta p {
        display: -webkit-box !important;
        -webkit-line-clamp: 1 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
        margin: 0 !important;
        font-size: 0.55rem !important;
        line-height: 1.02 !important;
    }
}

/* Messages list final override (mobile) */
@media (max-width: 900px) {
    body.messages-page.is-authenticated:not(.conversation-open) .chat-layout {
        grid-template-columns: 1fr !important;
        min-height: calc(100dvh - 126px) !important;
        max-height: calc(100dvh - 126px) !important;
        gap: 0 !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-main {
        display: none !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-sidebar {
        display: grid !important;
        grid-template-rows: auto minmax(0, 1fr) !important;
        min-height: calc(100dvh - 126px) !important;
        max-height: calc(100dvh - 126px) !important;
        overflow: hidden !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contacts-list {
        min-height: 0 !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        padding: 2px !important;
        gap: 2px !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-item,
    body.messages-page.is-authenticated:not(.conversation-open) .contact-row-link {
        grid-template-columns: 18px minmax(0, 1fr) auto !important;
        align-items: center !important;
        min-height: 32px !important;
        padding: 2px 4px !important;
        gap: 3px !important;
        border-radius: 6px !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-item .avatar {
        width: 18px !important;
        height: 18px !important;
        font-size: 0.52rem !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-meta-top strong {
        font-size: 0.64rem !important;
        line-height: 1.02 !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-time {
        font-size: 0.48rem !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-meta > small.muted {
        display: none !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-meta p {
        display: -webkit-box !important;
        -webkit-line-clamp: 1 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
        margin: 0 !important;
        font-size: 0.56rem !important;
        line-height: 1.04 !important;
    }
}

@media (max-width: 520px) {
    body.messages-page.is-authenticated:not(.conversation-open) .chat-layout,
    body.messages-page.is-authenticated:not(.conversation-open) .chat-sidebar {
        min-height: calc(100dvh - 120px) !important;
        max-height: calc(100dvh - 120px) !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-item,
    body.messages-page.is-authenticated:not(.conversation-open) .contact-row-link {
        min-height: 30px !important;
    }
}

/* Messages list micro-size override (mobile): much smaller rows, slightly bigger text */
@media (max-width: 900px) {
    body.messages-page.is-authenticated:not(.conversation-open) .contacts-list {
        padding: 1px !important;
        gap: 1px !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-item,
    body.messages-page.is-authenticated:not(.conversation-open) .contact-row-link {
        grid-template-columns: 14px minmax(0, 1fr) auto !important;
        min-height: 22px !important;
        padding: 1px 3px !important;
        gap: 2px !important;
        border-radius: 4px !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-item .avatar {
        width: 14px !important;
        height: 14px !important;
        font-size: 0.46rem !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-meta-top {
        gap: 2px !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-meta-top strong {
        font-size: 0.69rem !important;
        line-height: 1.02 !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-time {
        font-size: 0.53rem !important;
        line-height: 1 !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-meta p {
        margin: 0 !important;
        font-size: 0.6rem !important;
        line-height: 1.02 !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 1 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-item .badge {
        min-width: 10px !important;
        height: 10px !important;
        padding: 0 2px !important;
        font-size: 0.46rem !important;
        line-height: 10px !important;
    }
}

@media (max-width: 520px) {
    body.messages-page.is-authenticated:not(.conversation-open) .contact-item,
    body.messages-page.is-authenticated:not(.conversation-open) .contact-row-link {
        grid-template-columns: 13px minmax(0, 1fr) auto !important;
        min-height: 20px !important;
        padding: 1px 2px !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-item .avatar {
        width: 13px !important;
        height: 13px !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-meta-top strong {
        font-size: 0.66rem !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .contact-meta p {
        font-size: 0.58rem !important;
    }
}

/* Messages list absolute final compact override (mobile) */
@media (max-width: 900px) {
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .chat-sidebar-head {
        padding: 4px 6px !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .chat-subtitle {
        display: none !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .chat-contact-search-wrap {
        margin-top: 3px !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .chat-contact-search-wrap label {
        display: none !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .chat-contact-search {
        height: 26px !important;
        padding: 4px 8px !important;
        font-size: 0.7rem !important;
        border-radius: 7px !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contacts-list {
        padding: 1px !important;
        gap: 1px !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item,
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link {
        grid-template-columns: 15px minmax(0, 1fr) auto !important;
        align-items: center !important;
        min-height: 21px !important;
        padding: 1px 3px !important;
        gap: 2px !important;
        border-radius: 4px !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item .avatar,
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link .avatar {
        width: 15px !important;
        height: 15px !important;
        font-size: 0.44rem !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta {
        min-width: 0 !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta-top {
        gap: 2px !important;
        align-items: center !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta-top strong {
        font-size: 0.72rem !important;
        line-height: 1.02 !important;
        min-width: 0 !important;
        overflow: hidden !important;
        white-space: nowrap !important;
        text-overflow: ellipsis !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-time {
        font-size: 0.48rem !important;
        line-height: 1 !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta > small.muted {
        display: none !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta p {
        margin: 0 !important;
        font-size: 0.62rem !important;
        line-height: 1.02 !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 1 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item .badge,
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link .badge {
        min-width: 9px !important;
        height: 9px !important;
        padding: 0 1px !important;
        font-size: 0.42rem !important;
        line-height: 9px !important;
    }
}

@media (max-width: 520px) {
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item,
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link {
        grid-template-columns: 14px minmax(0, 1fr) auto !important;
        min-height: 19px !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item .avatar,
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link .avatar {
        width: 14px !important;
        height: 14px !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta-top strong {
        font-size: 0.69rem !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta p {
        font-size: 0.59rem !important;
    }
}

/* Handheld forced compact chat list (final, cache-safe) */
html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) {
    grid-template-columns: 1fr !important;
    gap: 0 !important;
    min-height: calc(100dvh - 120px) !important;
    max-height: calc(100dvh - 120px) !important;
}

html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .chat-main {
    display: none !important;
}

html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .chat-sidebar {
    display: grid !important;
    grid-template-rows: auto minmax(0, 1fr) !important;
    min-height: calc(100dvh - 120px) !important;
    max-height: calc(100dvh - 120px) !important;
    overflow: hidden !important;
    border-radius: 8px !important;
}

html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .chat-sidebar-head {
    padding: 3px 5px !important;
}

html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .chat-subtitle {
    display: none !important;
}

html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .chat-contact-search-wrap {
    margin-top: 2px !important;
}

html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .chat-contact-search-wrap label {
    display: none !important;
}

html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .chat-contact-search {
    height: 24px !important;
    padding: 3px 7px !important;
    font-size: 0.68rem !important;
    border-radius: 6px !important;
}

html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contacts-list {
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 1px !important;
    gap: 1px !important;
}

html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item,
html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link {
    display: grid !important;
    grid-template-columns: 14px minmax(0, 1fr) auto !important;
    align-items: center !important;
    min-height: 20px !important;
    padding: 1px 3px !important;
    gap: 2px !important;
    border-radius: 4px !important;
}

html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item .avatar,
html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link .avatar {
    width: 14px !important;
    height: 14px !important;
    font-size: 0.42rem !important;
}

html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta {
    min-width: 0 !important;
}

html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta-top {
    gap: 2px !important;
}

html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta-top strong {
    font-size: 0.72rem !important;
    line-height: 1.01 !important;
    min-width: 0 !important;
    overflow: hidden !important;
    white-space: nowrap !important;
    text-overflow: ellipsis !important;
}

html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-time {
    font-size: 0.47rem !important;
    line-height: 1 !important;
}

html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta > small.muted {
    display: none !important;
}

html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta p {
    margin: 0 !important;
    font-size: 0.62rem !important;
    line-height: 1.01 !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 1 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
}

html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item .badge,
html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link .badge {
    min-width: 8px !important;
    height: 8px !important;
    padding: 0 1px !important;
    font-size: 0.4rem !important;
    line-height: 8px !important;
}

/* Fix stretched conversation cards in mobile list */
@media (max-width: 900px) {
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contacts-list,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contacts-list {
        align-content: start !important;
        justify-content: start !important;
        align-items: start !important;
        grid-auto-rows: min-content !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item,
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link {
        align-self: start !important;
        height: auto !important;
        max-height: none !important;
    }
}

/* FINAL FINAL: messages list balanced size (must stay last) */
@media (max-width: 900px) {
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contacts-list,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contacts-list {
        padding: 4px !important;
        gap: 5px !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item,
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link {
        display: grid !important;
        grid-template-columns: 30px minmax(0, 1fr) auto !important;
        min-height: 52px !important;
        padding: 6px 8px !important;
        gap: 8px !important;
        border-radius: 10px !important;
        align-items: center !important;
        align-self: start !important;
        height: auto !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item .avatar,
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link .avatar,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item .avatar,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link .avatar {
        width: 30px !important;
        height: 30px !important;
        font-size: 0.72rem !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta-top strong,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta-top strong {
        font-size: 0.86rem !important;
        line-height: 1.15 !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-time,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-time {
        font-size: 0.66rem !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta p,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta p {
        margin: 2px 0 0 !important;
        font-size: 0.76rem !important;
        line-height: 1.2 !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 1 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item .badge,
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link .badge,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item .badge,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link .badge {
        min-width: 14px !important;
        height: 14px !important;
        font-size: 0.58rem !important;
        line-height: 14px !important;
        padding: 0 3px !important;
    }
}

@media (max-width: 520px) {
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item,
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link {
        grid-template-columns: 28px minmax(0, 1fr) auto !important;
        min-height: 48px !important;
        padding: 5px 7px !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item .avatar,
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link .avatar,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item .avatar,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link .avatar {
        width: 28px !important;
        height: 28px !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta-top strong,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta-top strong {
        font-size: 0.82rem !important;
    }

    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta p,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta p {
        font-size: 0.74rem !important;
    }
}
















/* === EOF LOCK: AUTH + MESSAGES MOBILE (DO NOT MOVE) === */
@media (max-width: 900px) {
    html.is-handheld body.auth-body .auth-wrap,
    body.auth-body .auth-wrap {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 10px !important;
        align-items: start !important;
        min-height: auto !important;
    }

    html.is-handheld body.auth-body .auth-wrap > *,
    body.auth-body .auth-wrap > * {
        min-width: 0 !important;
        max-width: 100% !important;
    }

    html.is-handheld body.auth-body .auth-hero,
    body.auth-body .auth-hero {
        order: 1 !important;
        max-width: 100% !important;
        padding: 10px 8px !important;
    }

    html.is-handheld body.auth-body .auth-card,
    body.auth-body .auth-card {
        order: 2 !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 14px 12px !important;
        border-radius: 16px !important;
        overflow: hidden !important;
    }

    html.is-handheld body.auth-body .auth-card h2,
    body.auth-body .auth-card h2 {
        font-size: 1.9rem !important;
        line-height: 1.05 !important;
        margin-bottom: 10px !important;
    }

    html.is-handheld body.auth-body input,
    html.is-handheld body.auth-body textarea,
    html.is-handheld body.auth-body select,
    body.auth-body input,
    body.auth-body textarea,
    body.auth-body select {
        width: 100% !important;
        max-width: 100% !important;
        padding: 9px 10px !important;
        font-size: 0.9rem !important;
    }

    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contacts-list,
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contacts-list {
        padding: 4px !important;
        gap: 5px !important;
        align-content: start !important;
        justify-content: start !important;
        align-items: start !important;
        grid-auto-rows: min-content !important;
    }

    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link,
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item,
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link {
        display: grid !important;
        grid-template-columns: 30px minmax(0, 1fr) auto !important;
        min-height: 52px !important;
        padding: 6px 8px !important;
        gap: 8px !important;
        border-radius: 10px !important;
        align-items: center !important;
        align-self: start !important;
        height: auto !important;
        max-height: none !important;
    }

    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item .avatar,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link .avatar,
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item .avatar,
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link .avatar {
        width: 30px !important;
        height: 30px !important;
        font-size: 0.72rem !important;
    }

    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta-top strong,
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta-top strong {
        font-size: 0.86rem !important;
        line-height: 1.15 !important;
    }

    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-time,
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-time {
        font-size: 0.66rem !important;
        line-height: 1 !important;
    }

    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta p,
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-meta p {
        margin: 2px 0 0 !important;
        font-size: 0.76rem !important;
        line-height: 1.2 !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 1 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
    }

    html.is-handheld body.messages-page.conversation-open.is-authenticated .messages-list,
    html.is-handheld body.messages-page.conversation-open.is-authenticated .messages-list.messages-list-live,
    body.messages-page.conversation-open.is-authenticated .messages-list,
    body.messages-page.conversation-open.is-authenticated .messages-list.messages-list-live {
        align-content: start !important;
        justify-content: start !important;
        align-items: start !important;
        grid-auto-rows: min-content !important;
    }

    html.is-handheld body.messages-page.conversation-open.is-authenticated .bubble,
    body.messages-page.conversation-open.is-authenticated .bubble {
        align-self: start !important;
        height: auto !important;
        max-height: none !important;
    }

    html.is-handheld body.messages-page .bubble-head strong,
    body.messages-page .bubble-head strong {
        display: inline-flex !important;
    }
}

@media (max-width: 520px) {
    html.is-handheld body.auth-body .auth-card h2,
    body.auth-body .auth-card h2 {
        font-size: 1.7rem !important;
    }

    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item,
    html.is-handheld body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link,
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-item,
    body.messages-page.is-authenticated .chat-layout:not(.has-active-chat) .contact-row-link {
        grid-template-columns: 28px minmax(0, 1fr) auto !important;
        min-height: 48px !important;
        padding: 5px 7px !important;
    }
}
/* EOF lock v2: mobile conversation rows (authoritative, keep last) */
@media (max-width: 900px) {
    body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contacts-list,
    html.is-handheld body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contacts-list {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        justify-content: flex-start !important;
        align-content: flex-start !important;
        gap: 8px !important;
        padding: 8px !important;
        grid-auto-rows: auto !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-item,
    body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-row-link,
    html.is-handheld body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-item,
    html.is-handheld body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-row-link {
        display: grid !important;
        grid-template-columns: 40px minmax(0, 1fr) auto !important;
        align-items: center !important;
        min-height: 72px !important;
        height: auto !important;
        max-height: none !important;
        padding: 10px 11px !important;
        gap: 10px !important;
        border-radius: 14px !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-item .avatar,
    body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-row-link .avatar,
    html.is-handheld body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-item .avatar,
    html.is-handheld body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-row-link .avatar {
        width: 40px !important;
        height: 40px !important;
        font-size: 0.96rem !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-meta,
    html.is-handheld body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-meta {
        display: flex !important;
        flex-direction: column !important;
        gap: 4px !important;
        min-width: 0 !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-meta-top,
    html.is-handheld body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-meta-top {
        display: flex !important;
        align-items: flex-start !important;
        justify-content: space-between !important;
        gap: 8px !important;
        min-width: 0 !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-name-wrap,
    html.is-handheld body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-name-wrap {
        display: inline-flex !important;
        align-items: center !important;
        gap: 6px !important;
        min-width: 0 !important;
        max-width: calc(100% - 60px) !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-name-wrap .name-with-badge,
    html.is-handheld body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-name-wrap .name-with-badge {
        display: inline-flex !important;
        align-items: center !important;
        gap: 4px !important;
        min-width: 0 !important;
        max-width: 100% !important;
        overflow: hidden !important;
        white-space: nowrap !important;
        text-overflow: ellipsis !important;
        font-size: 1rem !important;
        line-height: 1.2 !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-time,
    html.is-handheld body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-time {
        flex: 0 0 auto !important;
        margin-left: 6px !important;
        font-size: 0.75rem !important;
        line-height: 1 !important;
        color: var(--text-muted) !important;
        white-space: nowrap !important;
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        padding: 0 !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-meta > small.muted,
    html.is-handheld body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-meta > small.muted {
        display: block !important;
        margin: 0 !important;
        font-size: 0.75rem !important;
        line-height: 1.1 !important;
        opacity: 0.85 !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-state-text,
    html.is-handheld body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-state-text {
        margin: 0 !important;
        font-size: 0.88rem !important;
        line-height: 1.2 !important;
        color: var(--text-soft) !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
}

@media (max-width: 520px) {
    body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-item,
    body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-row-link,
    html.is-handheld body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-item,
    html.is-handheld body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-row-link {
        grid-template-columns: 38px minmax(0, 1fr) auto !important;
        min-height: 66px !important;
        padding: 9px 10px !important;
        gap: 9px !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-item .avatar,
    body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-row-link .avatar,
    html.is-handheld body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-item .avatar,
    html.is-handheld body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-row-link .avatar {
        width: 38px !important;
        height: 38px !important;
        font-size: 0.92rem !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-name-wrap .name-with-badge,
    html.is-handheld body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-name-wrap .name-with-badge {
        font-size: 0.94rem !important;
    }

    body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-state-text,
    html.is-handheld body.messages-page.is-authenticated:not(.conversation-open) .chat-layout:not(.has-active-chat) .contact-state-text {
        font-size: 0.84rem !important;
    }
}
/* EOF lock v3: profile mobile cleanup (remove duplicate handle area + visible subject labels) */
@media (max-width: 900px) {
    body.profile-page.is-authenticated .ig-top-row {
        align-items: center !important;
        row-gap: 6px !important;
    }

    body.profile-page.is-authenticated .student-progress-card {
        width: 100% !important;
        max-width: 100% !important;
        padding: 6px 0 0 !important;
        margin-top: 6px !important;
        overflow: visible !important;
    }

    body.profile-page.is-authenticated .student-progress-row {
        width: 100% !important;
        display: grid !important;
        grid-template-columns: minmax(88px, 34%) minmax(0, 1fr) !important;
        column-gap: 8px !important;
        align-items: center !important;
        margin-top: 8px !important;
    }

    body.profile-page.is-authenticated .student-progress-head {
        grid-column: 1 !important;
        max-width: none !important;
        min-width: 0 !important;
    }

    body.profile-page.is-authenticated .student-progress-head span {
        display: block !important;
        font-size: 0.74rem !important;
        line-height: 1.15 !important;
        letter-spacing: 0 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    body.profile-page.is-authenticated .student-progress-track {
        grid-column: 2 !important;
        width: 100% !important;
        min-width: 0 !important;
        height: 8px !important;
    }

    body.profile-page.is-authenticated .student-progress-track span {
        min-width: 10px !important;
    }
}

@media (max-width: 520px) {
    body.profile-page.is-authenticated .student-progress-row {
        grid-template-columns: minmax(82px, 36%) minmax(0, 1fr) !important;
        column-gap: 7px !important;
    }

    body.profile-page.is-authenticated .student-progress-head span {
        font-size: 0.72rem !important;
    }

    body.profile-page.is-authenticated .student-progress-track {
        height: 8px !important;
    }
}
/* EOF lock v4: dedicated followers/following screen (Instagram-style flow) */
body.profile-connections-page .profile-connections-screen {
    max-width: 760px;
    margin: 0 auto;
    padding: 14px;
    display: grid;
    gap: 12px;
}

body.profile-connections-page .profile-connections-top {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
}

body.profile-connections-page .profile-connections-back {
    width: 36px;
    height: 36px;
    border-radius: 999px;
    border: 1px solid #c9dced;
    background: #edf4fb;
    color: #1f4d76;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

body.profile-connections-page .profile-connections-back .ui-icon {
    width: 16px;
    height: 16px;
}

body.profile-connections-page .profile-connections-head-copy h2 {
    margin: 0;
    font-size: 1.18rem;
}

body.profile-connections-page .profile-connections-head-copy p {
    margin-top: 2px;
}

body.profile-connections-page .profile-connections-search input {
    width: 100%;
    border-radius: 12px;
    padding: 10px 12px;
    border: 1px solid #c8dced;
    background: #f5f9ff;
    color: #173a58;
    font-size: 0.95rem;
}

body.profile-connections-page .profile-connections-list {
    display: grid;
    gap: 10px;
}

body.profile-connections-page .profile-connection-item {
    padding: 10px;
    border-radius: 14px;
}

body.profile-connections-page .profile-connection-meta {
    min-width: 0;
}

body.profile-connections-page .profile-connection-meta .name-with-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

body.profile-connections-page .profile-connection-self {
    opacity: 0.82;
    pointer-events: none;
}

body.theme-dark.profile-connections-page .profile-connections-back {
    border-color: #4a6f90;
    background: #17334b;
    color: #e8f3ff;
}

body.theme-dark.profile-connections-page .profile-connections-search input {
    border-color: #3c6180;
    background: #102b40;
    color: #e6f3ff;
}

@media (max-width: 900px) {
    body.profile-connections-page .profile-connections-screen {
        max-width: 100%;
        min-height: calc(100dvh - 128px);
        padding: 12px 10px;
        gap: 10px;
    }

    body.profile-connections-page .profile-connections-top {
        grid-template-columns: 34px minmax(0, 1fr);
        gap: 8px;
    }

    body.profile-connections-page .profile-connections-back {
        width: 32px;
        height: 32px;
    }

    body.profile-connections-page .profile-connections-head-copy h2 {
        font-size: 1.04rem;
    }

    body.profile-connections-page .profile-connections-search input {
        border-radius: 11px;
        padding: 9px 10px;
        font-size: 0.9rem;
    }

    body.profile-connections-page .profile-connection-item {
        padding: 9px;
        border-radius: 12px;
    }
}
/* Summary resources layout: level -> subject -> lesson order */
.resources-doc-library .resource-summary-level {
    border: 1px solid #d3e4f2;
    border-radius: 14px;
    background: #f8fcff;
    padding: 10px;
    display: grid;
    gap: 10px;
}

.resources-doc-library .resource-summary-level-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.resources-doc-library .resource-summary-level-head h5 {
    margin: 0;
    font-size: 1rem;
}

.resources-doc-library .resource-summary-level-body {
    display: grid;
    gap: 10px;
}

.resources-doc-library .resource-summary-subject {
    border: 1px solid #d8e8f6;
    border-radius: 12px;
    background: #ffffff;
    padding: 8px;
    display: grid;
    gap: 8px;
}

.resources-doc-library .resource-summary-subject-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.resources-doc-library .resource-summary-subject-head h6 {
    margin: 0;
    font-size: 0.92rem;
}

.resources-doc-library .resource-summary-subject-list {
    display: grid;
    gap: 8px;
}

body.theme-dark .resources-doc-library .resource-summary-level {
    border-color: #3f607d;
    background: #112d43;
}

body.theme-dark .resources-doc-library .resource-summary-subject {
    border-color: #3f607d;
    background: #0f2739;
}

@media (max-width: 900px) {
    .resources-doc-library .resource-summary-level {
        padding: 9px;
        gap: 8px;
    }

    .resources-doc-library .resource-summary-subject {
        padding: 7px;
        gap: 7px;
    }
}

/* ── Cookie banner ── */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: var(--card-bg, #fff);
    border-top: 1px solid var(--border-color, #dce8f2);
    padding: 14px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
    font-size: 0.88rem;
}

.cookie-banner p {
    flex: 1;
    margin: 0;
    min-width: 200px;
}

.cookie-banner-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* ── Footer legal links ── */
.footer-legal {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
    margin: 4px 0;
    font-size: 0.78rem;
}

.footer-legal a {
    color: var(--text-muted, #6b7a8d);
    text-decoration: none;
}

.footer-legal a:hover {
    text-decoration: underline;
}

/* ── Legal consent checkboxes at registration ── */
.legal-consent-block {
    display: grid;
    gap: 10px;
    margin: 16px 0;
}

.legal-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 0.88rem;
    cursor: pointer;
    line-height: 1.45;
}

.legal-checkbox input[type="checkbox"] {
    margin-top: 3px;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--color-primary, #4a6fa5);
}

.legal-checkbox a {
    color: var(--color-primary, #4a6fa5);
    text-decoration: underline;
}

/* ── Legal page content ── */
.legal-page {
    max-width: 720px;
    margin: 32px auto;
    padding: 0 16px;
}

.legal-page h1 {
    font-size: 1.6rem;
    margin-bottom: 8px;
}

.legal-page .legal-meta {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 32px;
}

.legal-page h2 {
    font-size: 1.1rem;
    margin-top: 28px;
    margin-bottom: 8px;
    color: var(--color-primary, #4a6fa5);
}

.legal-page p, .legal-page li {
    line-height: 1.7;
    font-size: 0.92rem;
    color: var(--text-body, #2d3748);
}

.legal-page ul {
    padding-left: 20px;
}

.legal-page section {
    margin-bottom: 16px;
}

/* ── Resource upload / moderation stats ── */
.resource-stats-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin: 16px 0;
}

.resource-stat-card {
    background: var(--card-bg, #f8fafc);
    border: 1px solid var(--border-color, #dce8f2);
    border-radius: 10px;
    padding: 12px 18px;
    text-align: center;
    min-width: 90px;
    flex: 1;
}

.resource-stat-card strong {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-primary, #4a6fa5);
}

.resource-stat-card span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.resource-upload-form .form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

@media (max-width: 600px) {
    .resource-upload-form .form-grid-2 {
        grid-template-columns: 1fr;
    }
}

.mod-section-details {
    border: 1px solid var(--border-color, #dce8f2);
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 16px;
}

.mod-section-details summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 4px 0;
}

.mod-section-details[open] summary {
    margin-bottom: 16px;
}

/* ── API Docs page ── */
.api-docs { max-width: 800px; margin: 32px auto; padding: 0 16px; }
.api-docs h1 { font-size: 1.7rem; margin-bottom: 4px; }
.api-docs .api-version { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 32px; }
.api-docs h2 { font-size: 1.15rem; margin: 32px 0 12px; border-bottom: 2px solid var(--border-color, #dce8f2); padding-bottom: 6px; }
.endpoint-card { border: 1px solid var(--border-color, #dce8f2); border-radius: 10px; padding: 16px 20px; margin-bottom: 12px; }
.endpoint-card h3 { font-size: 1rem; display: flex; align-items: center; gap: 10px; margin: 0 0 8px; }
.method-badge { font-size: 0.72rem; font-weight: 700; letter-spacing: .04em; padding: 3px 8px; border-radius: 5px; text-transform: uppercase; }
.method-badge.get { background: #dbeafe; color: #1d4ed8; }
.method-badge.post { background: #dcfce7; color: #15803d; }
.code-block { background: #1e293b; color: #e2e8f0; font-size: 0.8rem; padding: 12px 16px; border-radius: 8px; overflow-x: auto; margin: 8px 0; font-family: 'Courier New', monospace; line-height: 1.5; }
.api-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; margin: 8px 0; }
.api-table th, .api-table td { padding: 8px 12px; border: 1px solid var(--border-color, #dce8f2); text-align: left; }
.api-table th { background: var(--card-bg, #f8fafc); font-weight: 600; }

/* ── API Keys in settings ── */
.api-keys-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; margin: 12px 0; }
.api-keys-table th, .api-keys-table td { padding: 8px 12px; border-bottom: 1px solid var(--border-color, #dce8f2); }
.api-keys-table th { font-weight: 600; color: var(--text-muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: .04em; }
.api-key-revoked { opacity: 0.5; }
.api-key-code { display: block; font-family: 'Courier New', monospace; font-size: 0.85rem; background: #f0f4f8; padding: 8px 12px; border-radius: 6px; word-break: break-all; margin: 6px 0; }
.api-key-reveal { margin-bottom: 16px; }
.badge-green { background: #dcfce7; color: #15803d; padding: 2px 8px; border-radius: 999px; font-size: 0.75rem; }
.badge-grey { background: #f1f5f9; color: #6b7a8d; padding: 2px 8px; border-radius: 999px; font-size: 0.75rem; }

/* ── Story reply dans les messages ── sans bulle ── */
.msg-story-reply {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 2px 0;
}
.msg-story-reply-label {
    font-size: 0.75rem;
    font-weight: 500;
    opacity: .6;
    margin: 0;
}
.msg-story-reply-ref {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}
.msg-story-reply-arrow {
    font-size: 1.1rem;
    opacity: .45;
    flex-shrink: 0;
    margin-top: 4px;
    line-height: 1;
}
.msg-story-reply-thumb {
    width: 90px;
    height: 120px;
    border-radius: 10px;
    object-fit: cover;
    display: block;
    border: 1px solid rgba(255,255,255,.15);
    box-shadow: 0 2px 10px rgba(0,0,0,.35);
}
.msg-story-reply-thumb-empty {
    width: 90px;
    height: 120px;
    border-radius: 10px;
    background: rgba(255,255,255,.07);
    display: block;
    border: 1px solid rgba(255,255,255,.12);
}
.msg-story-reply-text-bubble {
    margin-top: 4px !important;
    display: inline-block !important;
}
.msg-story-reply-text {
    font-size: 0.92rem;
    margin: 0;
    word-break: break-word;
}

/* ══════════════════════════════════════════════════════════════
   STORY VIEWER — INSTAGRAM-STYLE REDESIGN
   Placed last in file: wins all specificity battles.
   ══════════════════════════════════════════════════════════════ */

/* Overlay container */
#story-viewer.story-viewer {
    position: fixed !important;
    inset: 0 !important;
    z-index: 9999 !important;
    display: grid !important;
    place-items: center !important;
    pointer-events: all !important;
    padding: 12px !important;
    box-sizing: border-box !important;
}
#story-viewer.story-viewer[hidden] { display: none !important; }

/* Backdrop flouté */
#story-viewer .story-viewer-backdrop {
    position: fixed !important;
    inset: 0 !important;
    background: rgba(0,0,0,.82) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    z-index: 0 !important;
}

/* Panneau principal — ratio 9:16 Instagram */
#story-viewer .story-viewer-panel {
    position: relative !important;
    z-index: 1 !important;
    /* On force la hauteur MAXIMALE prioritaire, la largeur s'adaptera */
    height: min(90dvh, 850px) !important;
    width: auto !important;
    aspect-ratio: 9 / 16 !important;
    max-width: 94vw !important;
    border-radius: 24px !important;
    overflow: hidden !important;
    background: #000 !important;
    box-shadow: 0 30px 100px rgba(0,0,0,.9), 0 0 0 1px rgba(255,255,255,.08) !important;
    align-self: center !important;
    justify-self: center !important;
    flex-shrink: 0 !important;
}

/* Image — plein fond absolu */
#story-viewer-image.story-viewer-image {
    position: absolute !important;
    top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
    border-radius: 0 !important;
    z-index: 1 !important;
    /* On évite les comportements bizarres des navigateurs sur l'absolute */
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}

/* Barre de progression */
#story-viewer .sv-progress {
    position: absolute !important;
    top: 12px !important;
    left: 14px !important;
    right: 14px !important;
    height: 3px !important;
    background: rgba(255,255,255,.38) !important;
    border-radius: 99px !important;
    z-index: 10 !important;
    overflow: hidden !important;
    box-shadow: 0 1px 3px rgba(0,0,0,.4) !important;
}
#sv-progress-bar {
    height: 100% !important;
    width: 0%;               /* PAS de !important — le JS doit pouvoir l'animer */
    background: #fff !important;
    border-radius: 99px !important;
}

/* Topbar */
#story-viewer .story-viewer-topbar {
    position: absolute !important;
    top: 28px !important;
    left: 12px !important;
    right: 12px !important;
    z-index: 10 !important;
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 0 !important;
    background: none !important;
}

/* Avatar cercle */
#story-viewer .sv-avatar-wrap { flex-shrink: 0 !important; }
#story-viewer .sv-avatar,
#story-viewer #sv-avatar-el {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 38px !important;
    height: 38px !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, #ff5520, #ff9500) !important;
    color: #fff !important;
    font-weight: 700 !important;
    font-size: 0.9rem !important;
    border: 2px solid rgba(255,255,255,.75) !important;
    overflow: hidden !important;
    flex-shrink: 0 !important;
    text-transform: uppercase !important;
}
#story-viewer #sv-avatar-el img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    border-radius: 50% !important;
    max-width: none !important;
}

/* Nom + heure */
#story-viewer .sv-user-meta {
    flex: 1 !important;
    min-width: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 1px !important;
}
#story-viewer #story-viewer-user {
    display: block !important;
    color: #fff !important;
    font-size: 0.9rem !important;
    font-weight: 700 !important;
    text-shadow: 0 1px 6px rgba(0,0,0,.7) !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}
#story-viewer #story-viewer-time {
    display: block !important;
    color: rgba(255,255,255,.68) !important;
    font-size: 0.72rem !important;
    font-weight: 400 !important;
}

/* Bouton fermer (dans topbar) */
#story-viewer .story-viewer-close {
    position: static !important;
    inset: unset !important;
    flex-shrink: 0 !important;
    width: 34px !important;
    height: 34px !important;
    border-radius: 50% !important;
    background: rgba(0,0,0,.45) !important;
    border: none !important;
    color: #fff !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    backdrop-filter: blur(6px) !important;
    -webkit-backdrop-filter: blur(6px) !important;
    transition: background 150ms !important;
    z-index: auto !important;
}
#story-viewer .story-viewer-close:hover { background: rgba(210,40,20,.8) !important; }

/* Boutons nav — style Instagram : chevrons blancs subtils À L'EXTÉRIEUR du panneau sur desktop */
#story-viewer .story-nav-btn {
    position: fixed !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 10 !important;
    width: 42px !important;
    height: 42px !important;
    border-radius: 50% !important;
    background: rgba(255,255,255,.92) !important;
    border: none !important;
    color: #262626 !important;
    font-size: 1.4rem !important;
    font-weight: 400 !important;
    line-height: 1 !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 2px 12px rgba(0,0,0,.4) !important;
    transition: opacity 150ms, transform 120ms !important;
    padding: 0 !important;
    opacity: .85 !important;
}
#story-viewer .story-nav-prev { left: calc(50% - min(210px, 47vw) - 54px) !important; right: auto !important; }
#story-viewer .story-nav-next { right: calc(50% - min(210px, 47vw) - 54px) !important; left: auto !important; }
#story-viewer .story-nav-btn:hover { opacity: 1 !important; transform: translateY(-50%) scale(1.08) !important; }
#story-viewer .story-nav-btn[hidden] { display: none !important; }

/* Gradient de fondu haut (lisibilité topbar sur images claires) */
#story-viewer .story-viewer-panel::before {
    content: "" !important;
    position: absolute !important;
    top: 0 !important; left: 0 !important; right: 0 !important;
    height: 140px !important;
    background: linear-gradient(to bottom, rgba(0,0,0,.82) 0%, rgba(0,0,0,.35) 55%, transparent 100%) !important;
    z-index: 2 !important;
    pointer-events: none !important;
    border-radius: 24px 24px 0 0 !important;
}

/* Gradient bas pour solidifier l'input (masque les malformations de l'image en bas) */
#story-viewer .story-viewer-panel::after {
    content: "" !important;
    display: block !important;
    position: absolute !important;
    bottom: 0 !important; left: 0 !important; right: 0 !important;
    height: 160px !important;
    background: linear-gradient(to top, rgba(0,0,0,.9) 0%, rgba(0,0,0,.5) 50%, transparent 100%) !important;
    z-index: 2 !important;
    pointer-events: none !important;
    border-radius: 0 0 24px 24px !important;
}

/* Barre de réponse — Instagram style : input pill + boutons à droite */
#story-viewer .story-reply-bar[hidden] { display: none !important; }
#story-viewer .story-reply-bar {
    position: absolute !important;
    left: 12px !important;
    right: 12px !important;
    bottom: 14px !important;
    z-index: 20 !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 0 !important;
    border-radius: 0 !important;
    border: none !important;
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    grid-template-columns: unset !important;
    box-shadow: none !important;
}
#story-viewer .story-reply-bar input {
    flex: 1 !important;
    border: 1.2px solid rgba(255,255,255,.7) !important;
    background: rgba(0,0,0,.35) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    color: #fff !important;
    font-size: 0.9rem !important;
    padding: 10px 16px !important;
    border-radius: 999px !important;
    outline: none !important;
    min-width: 0 !important;
    height: 40px !important;
    box-sizing: border-box !important;
}
#story-viewer .story-reply-bar input::placeholder { color: rgba(255,255,255,.7) !important; }
#story-viewer .story-reply-bar input:disabled {
    opacity: .5 !important;
    cursor: not-allowed !important;
    border-color: rgba(255,255,255,.3) !important;
}

/* Bouton envoi — caché quand input disabled (propre story) */
#story-viewer .sv-send-btn { display: none !important; }
#story-viewer .story-reply-bar:has(input:not(:disabled)) .sv-send-btn { display: flex !important; }

/* Boutons action ❤ ✈ — transparents, icône seule (style Instagram) */
#story-viewer .sv-action-btn {
    flex-shrink: 0 !important;
    width: 34px !important;
    height: 34px !important;
    border-radius: 50% !important;
    background: transparent !important;
    border: none !important;
    color: #fff !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background 150ms, transform 120ms !important;
    padding: 0 !important;
}
#story-viewer .sv-action-btn svg {
    width: 24px !important;
    height: 24px !important;
    filter: drop-shadow(0 1px 3px rgba(0,0,0,.7)) !important;
}
#story-viewer .sv-action-btn:hover { transform: scale(1.15) !important; }
#story-viewer .sv-action-btn.active { color: #ff2d55 !important; }
#story-viewer .sv-action-btn.active svg { fill: #ff2d55 !important; }
#story-viewer .sv-action-btn[hidden] { display: none !important; }

/* Status réponse */
#story-viewer .sv-reply-status,
#story-reply-status {
    position: absolute !important;
    bottom: 60px !important;
    left: 16px !important;
    right: 16px !important;
    text-align: center !important;
    color: rgba(255,255,255,.8) !important;
    font-size: 0.75rem !important;
    z-index: 10 !important;
    pointer-events: none !important;
}

/* ── Owner bar ─────────────────────────────────────────── */
#story-viewer .sv-owner-bar[hidden] { display: none !important; }
#story-viewer .sv-owner-bar {
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 10 !important;
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 12px 16px 18px !important;
    background: linear-gradient(to top, rgba(0,0,0,.65) 0%, transparent 100%) !important;
}
#story-viewer .sv-owner-views-btn {
    display: flex !important;
    align-items: center !important;
    gap: 7px !important;
    background: rgba(255,255,255,.15) !important;
    border: none !important;
    border-radius: 999px !important;
    padding: 7px 14px !important;
    color: #fff !important;
    font-size: .88rem !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    backdrop-filter: blur(8px) !important;
    transition: background .15s !important;
    flex-shrink: 0 !important;
}
#story-viewer .sv-owner-views-btn:hover { background: rgba(255,255,255,.25) !important; }
#story-viewer .sv-owner-stats {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    flex: 1 !important;
}
#story-viewer .sv-stat {
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
    color: rgba(255,255,255,.85) !important;
    font-size: .82rem !important;
    font-weight: 600 !important;
}
#story-viewer .sv-stat svg { opacity: .85; }
#story-viewer .sv-owner-delete-btn {
    width: 36px !important;
    height: 36px !important;
    border-radius: 50% !important;
    border: none !important;
    background: rgba(255,60,60,.18) !important;
    color: rgba(255,120,120,.9) !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background .15s !important;
    flex-shrink: 0 !important;
}
#story-viewer .sv-owner-delete-btn:hover { background: rgba(255,60,60,.35) !important; }

/* ── Viewers panel (owner) ──────────────────────────────── */
#story-viewer .sv-viewers-panel[hidden] { display: none !important; }
#story-viewer .sv-viewers-panel {
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 12 !important;
    background: rgba(8,18,30,.97) !important;
    backdrop-filter: blur(20px) !important;
    border-top: 1px solid rgba(255,255,255,.1) !important;
    border-radius: 18px 18px 0 0 !important;
    max-height: 65% !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    animation: ssp-up .22s cubic-bezier(.22,1,.36,1) !important;
}
.sv-vp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 10px;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sv-vp-title {
    font-size: .9rem;
    font-weight: 700;
    color: #e8f4ff;
}
.sv-vp-close {
    width: 26px; height: 26px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,.1);
    cursor: pointer;
    color: #e8f4ff;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s;
}
.sv-vp-close:hover { background: rgba(255,255,255,.2); }
.sv-vp-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px 0 12px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.15) transparent;
}
.sv-vp-list::-webkit-scrollbar { width: 4px; }
.sv-vp-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 2px; }
.sv-vp-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 16px;
    color: #daeeff;
}
.sv-vp-av {
    width: 40px; height: 40px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: linear-gradient(135deg, #5fa8d3, #ff7040);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .9rem; color: #fff;
}
.sv-vp-av img { width: 100%; height: 100%; object-fit: cover; }
.sv-vp-name {
    flex: 1;
    font-size: .88rem;
    font-weight: 600;
}
.sv-vp-time {
    font-size: .75rem;
    opacity: .5;
    flex-shrink: 0;
}
.sv-vp-empty {
    text-align: center;
    padding: 24px;
    font-size: .85rem;
    color: rgba(200,223,242,.35);
}

/* Panel partage story — redesigné */
#story-viewer .story-share-panel[hidden] {
    display: none !important;
}
#story-viewer .story-share-panel {
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 11 !important;
    background: rgba(8,18,30,.96) !important;
    backdrop-filter: blur(20px) !important;
    border-top: 1px solid rgba(255,255,255,.1) !important;
    border-radius: 18px 18px 0 0 !important;
    padding: 0 !important;
    max-height: 72% !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    animation: ssp-up .22s cubic-bezier(.22,1,.36,1) !important;
    box-sizing: border-box !important;
    width: 100% !important;
}
@keyframes ssp-up {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}
.ssp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 8px;
    flex-shrink: 0;
}
.ssp-title {
    font-size: .9rem;
    font-weight: 700;
    color: #e8f4ff;
}
.ssp-close {
    width: 26px; height: 26px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,.1);
    cursor: pointer;
    color: #e8f4ff;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s;
}
.ssp-close:hover { background: rgba(255,255,255,.2); }
.ssp-search-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: rgba(255,255,255,.04);
    border-top: 1px solid rgba(255,255,255,.07);
    border-bottom: 1px solid rgba(255,255,255,.07);
    flex-shrink: 0;
}
.ssp-search-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: .85rem;
    color: #c8dff2;
    outline: none;
}
.ssp-search-input::placeholder { color: rgba(200,223,242,.4); }
.story-share-contacts {
    flex: 1;
    overflow-y: auto;
    padding: 6px 0;
}
#story-viewer .story-share-contacts {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
    display: block;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.15) transparent;
}
#story-viewer .story-share-contacts::-webkit-scrollbar { width: 4px; }
#story-viewer .story-share-contacts::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 2px; }
.ssp-contact {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    width: 100% !important;
    padding: 9px 20px 9px 16px !important;
    background: transparent !important;
    border: none !important;
    cursor: pointer !important;
    color: #e8f4ff !important;
    text-align: left !important;
    transition: background .12s !important;
    box-sizing: border-box !important;
}
.ssp-contact:hover { background: rgba(255,255,255,.06) !important; }
.ssp-contact.sent .ssp-send-label { color: #43e097 !important; }
.ssp-av {
    width: 40px; height: 40px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: linear-gradient(135deg, #5fa8d3, #ff7040);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: .9rem;
    color: #fff;
}
.ssp-av-img { width: 100%; height: 100%; object-fit: cover; }
.ssp-name {
    flex: 1;
    font-size: .88rem;
    font-weight: 600;
    color: #daeeff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.ssp-send-label {
    font-size: .8rem;
    font-weight: 700;
    color: #5fa8d3;
    flex-shrink: 0;
    white-space: nowrap;
    padding-left: 6px;
    transition: color .2s;
}
.ssp-empty {
    text-align: center;
    padding: 20px;
    font-size: .83rem;
    color: rgba(200,223,242,.4);
}
.ssp-status {
    display: block;
    text-align: center;
    padding: 6px 12px 12px;
    font-size: .82rem;
    color: #43e097;
    min-height: 28px;
    flex-shrink: 0;
}

/* Mobile plein écran — arrows DANS le panneau (pas d'espace extérieur) */
@media (max-width: 520px) {
    #story-viewer.story-viewer {
        padding: 0 !important;
    }
    #story-viewer .story-viewer-panel {
        width: 100vw !important;
        height: 100dvh !important;
        max-width: none !important;
        max-height: none !important;
        border-radius: 0 !important;
        aspect-ratio: auto !important; /* Libère le ratio sur mobile */
    }
    #story-viewer .story-nav-btn {
        position: absolute !important;
        background: rgba(0,0,0,.35) !important;
        color: #fff !important;
        box-shadow: none !important;
        width: 36px !important;
        height: 36px !important;
    }
    #story-viewer .story-nav-prev { left: 8px !important; }
    #story-viewer .story-nav-next { right: 8px !important; }
    #story-viewer .story-viewer-panel::before { border-radius: 0 !important; }
    #story-viewer .story-viewer-panel::after { border-radius: 0 !important; }
}
/* ============================================
   Floating ZerinoBot tutor widget (bottom-left)
   — Style aligned with the messaging chat (msg-bubble).
   ===================================================== */
.zerino-assistant-fab {
    position: fixed;
    left: 20px;
    bottom: 22px;
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    z-index: 96;
    background: linear-gradient(135deg, #ff7f50 0%, #ff4d1a 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 14px 32px rgba(255, 80, 30, 0.32);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.zerino-assistant-fab:hover,
.zerino-assistant-fab:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 18px 38px rgba(255, 80, 30, 0.42);
    outline: none;
}
.zerino-assistant-fab[aria-expanded="true"] { transform: scale(0.94); }
.zerino-assistant-fab-mark {
    width: 78%;
    height: 78%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.zerino-assistant-fab-mark img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 1px 2px rgba(120, 30, 0, 0.18));
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}
.zerino-assistant-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: inherit;
    pointer-events: none;
    user-select: none;
}
/* Drag affordance */
.zerino-assistant-fab.is-dragging {
    cursor: grabbing;
    transition: none !important;
}
.zerino-assistant-fab.is-dragging .zerino-assistant-fab-pulse {
    display: none;
}
.zerino-assistant-fab.is-positioned .zerino-assistant-fab-pulse {
    /* Keep the pulse but tone it down once user has moved the fab */
    opacity: 0.6;
}
.zerino-assistant-fab-pulse {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    animation: zerino-assistant-pulse 2.4s ease-out infinite;
    pointer-events: none;
}
@keyframes zerino-assistant-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(255, 127, 80, 0.45); }
    70%  { box-shadow: 0 0 0 18px rgba(255, 127, 80, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 127, 80, 0); }
}

.zerino-assistant-panel {
    position: fixed;
    left: 20px;
    bottom: 88px;
    width: min(380px, calc(100vw - 32px));
    height: min(560px, calc(100vh - 140px));
    z-index: 97;
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 28px 64px rgba(10, 40, 80, 0.28);
    border: 1px solid rgba(191, 214, 233, 0.7);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: zerino-assistant-rise 0.18s ease-out;
}
@keyframes zerino-assistant-rise {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.zerino-assistant-panel[hidden] { display: none; }

.zerino-assistant-backdrop {
    position: fixed;
    inset: 0;
    z-index: 96;
    background: transparent;
    pointer-events: none;
}
.zerino-assistant-backdrop[hidden] { display: none; }
@media (max-width: 900px) {
    .zerino-assistant-backdrop {
        background: rgba(8, 19, 31, 0.45);
        backdrop-filter: blur(2px);
        pointer-events: auto;
        animation: zerino-assistant-fade 0.18s ease-out;
    }
    @keyframes zerino-assistant-fade {
        from { opacity: 0; }
        to   { opacity: 1; }
    }
}

.zerino-assistant-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    background: linear-gradient(135deg, #ff7f50 0%, #ff4d1a 100%);
    color: #fff;
    flex-shrink: 0;
}
.zerino-assistant-identity {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.zerino-assistant-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Fraunces', Georgia, serif;
    font-weight: 700;
    font-size: 1.05rem;
    flex-shrink: 0;
}
.zerino-assistant-title {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.1;
}
.zerino-assistant-subtitle {
    margin: 2px 0 0;
    font-size: 0.74rem;
    opacity: 0.85;
}
.zerino-assistant-close {
    background: rgba(255, 255, 255, 0.18);
    border: none;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease;
    flex-shrink: 0;
}
.zerino-assistant-close:hover { background: rgba(255, 255, 255, 0.32); }
.zerino-assistant-close svg { width: 14px; height: 14px; }

.zerino-assistant-log {
    list-style: none;
    margin: 0;
    padding: 14px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: transparent;
    scrollbar-width: thin;
    scrollbar-color: rgba(120, 160, 196, 0.25) transparent;
}
.zerino-assistant-log::-webkit-scrollbar { width: 3px; }
.zerino-assistant-log::-webkit-scrollbar-track { background: transparent; }
.zerino-assistant-log::-webkit-scrollbar-thumb {
    background: rgba(120, 160, 196, 0.25);
    border-radius: 999px;
}
.zerino-assistant-log::-webkit-scrollbar-button { display: none; height: 0; width: 0; }

.zerino-assistant-hint {
    text-align: center;
    color: #6b8299;
    font-size: 0.85rem;
    padding: 24px 16px;
    list-style: none;
}

/* Bubble layout — same vocabulary as .msg-bubble in messages.html */
.zerino-assistant-msg {
    max-width: min(320px, 86%);
    display: flex;
    flex-direction: column;
    gap: 3px;
    animation: zerino-assistant-bubble-in 160ms ease both;
}
@keyframes zerino-assistant-bubble-in {
    from { opacity: 0; transform: translateY(5px) scale(.98); }
    to   { opacity: 1; transform: none; }
}
.zerino-assistant-msg-assistant { align-self: flex-start; }
.zerino-assistant-msg-user      { align-self: flex-end; }

.zerino-assistant-bubble {
    padding: 9px 13px;
    border-radius: 18px;
    font-size: 0.9rem;
    line-height: 1.45;
    word-break: break-word;
    white-space: pre-wrap;
}
.zerino-assistant-msg-assistant .zerino-assistant-bubble {
    background: rgba(230, 241, 252, 0.9);
    color: #1a344f;
    border-bottom-left-radius: 5px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.07);
}
.zerino-assistant-msg-user .zerino-assistant-bubble {
    background: linear-gradient(135deg, #ff7f50, #ff4d1a);
    color: #fff;
    border-bottom-right-radius: 5px;
    box-shadow: 0 2px 8px rgba(255, 80, 30, 0.25);
}
.zerino-assistant-bubble a { color: inherit; text-decoration: underline; word-break: break-all; }

/* Streaming caret while text is being typed */
.zerino-assistant-bubble.is-streaming::after {
    content: "";
    display: inline-block;
    width: 2px;
    height: 1em;
    margin-left: 2px;
    vertical-align: -2px;
    background: currentColor;
    opacity: 0.7;
    animation: zerino-assistant-caret 0.9s steps(2) infinite;
}
@keyframes zerino-assistant-caret { 50% { opacity: 0; } }

/* Typing indicator (waiting for first token) — copy of .msg-typing-bubble */
.zerino-assistant-typing .zerino-assistant-bubble {
    display: inline-flex;
    gap: 5px;
    align-items: center;
    padding: 12px 16px;
    max-width: 70px;
}
.zerino-assistant-dots {
    display: inline-flex;
    gap: 5px;
}
.zerino-assistant-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #6b8299;
    display: inline-block;
    animation: zerino-assistant-dot 1.2s infinite ease-in-out both;
}
.zerino-assistant-dots span:nth-child(2) { animation-delay: 0.18s; }
.zerino-assistant-dots span:nth-child(3) { animation-delay: 0.36s; }
@keyframes zerino-assistant-dot {
    0%, 80%, 100% { transform: scale(0.65); opacity: 0.4; }
    40%           { transform: scale(1);    opacity: 1; }
}

.zerino-assistant-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid rgba(191, 214, 233, 0.45);
    background: #fff;
    flex-shrink: 0;
}
.zerino-assistant-input {
    flex: 1 1 auto;
    resize: none;
    border: 1px solid rgba(191, 214, 233, 0.6);
    border-radius: 18px;
    padding: 10px 14px;
    font: inherit;
    font-size: 0.92rem;
    color: #13253a;
    line-height: 1.4;
    background: #f7fafd;
    max-height: 120px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    scrollbar-width: thin;
    scrollbar-color: rgba(120, 160, 196, 0.25) transparent;
}
.zerino-assistant-input::-webkit-scrollbar { width: 3px; }
.zerino-assistant-input::-webkit-scrollbar-thumb { background: rgba(120, 160, 196, 0.25); border-radius: 999px; }
.zerino-assistant-input::-webkit-scrollbar-button { display: none; height: 0; }
.zerino-assistant-input:focus {
    outline: none;
    border-color: #ff7f50;
    box-shadow: 0 0 0 3px rgba(255, 127, 80, 0.18);
    background: #fff;
}
.zerino-assistant-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, #ff7f50, #ff4d1a);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, opacity 0.15s ease;
    flex-shrink: 0;
}
.zerino-assistant-send svg { width: 18px; height: 18px; }
.zerino-assistant-send:hover { transform: translateY(-1px); }
.zerino-assistant-send:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.zerino-assistant-form.is-busy .zerino-assistant-input { background: #eef3f9; }

.post-card-assistant-btn {
    color: #ff7f50;
    position: relative;
}
.post-card-assistant-btn .post-card-assistant-icon {
    width: 18px;
    height: 18px;
    stroke: currentColor;
}
.post-card-assistant-btn .post-card-assistant-label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1;
}
.post-card-assistant-btn:hover {
    color: #ff4d1a;
    background: rgba(255, 127, 80, 0.08);
}
.post-card-assistant-btn:hover .post-card-assistant-icon {
    transform: scale(1.1);
    filter: drop-shadow(0 0 4px rgba(255, 127, 80, 0.5));
}
@media (max-width: 520px) {
    .post-card-assistant-btn .post-card-assistant-label { display: none; }
}
body.theme-dark .post-card-assistant-btn:hover { background: rgba(255, 127, 80, 0.14); }

/* Mobile: full-width sheet docked above the bottom tabbar */
@media (max-width: 900px) {
    .zerino-assistant-fab {
        left: 14px;
        bottom: calc(96px + env(safe-area-inset-bottom));
        width: 50px;
        height: 50px;
    }
    .zerino-assistant-fab-mark { font-size: 1.3rem; }
    .zerino-assistant-panel {
        left: 8px;
        right: 8px;
        width: auto;
        bottom: calc(96px + env(safe-area-inset-bottom));
        height: min(70vh, calc(100vh - 200px));
        max-height: calc(100vh - 180px);
        border-radius: 18px;
    }
}

/* Dark theme — mirrors the messaging dark palette */
body.theme-dark .zerino-assistant-panel {
    background: #0f1d2d;
    border-color: rgba(255, 255, 255, 0.08);
    color: #e6edf6;
}
body.theme-dark .zerino-assistant-msg-assistant .zerino-assistant-bubble {
    background: rgba(28, 52, 72, 0.9);
    color: #e9f4ff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
body.theme-dark .zerino-assistant-form {
    background: #0f1d2d;
    border-top-color: rgba(255, 255, 255, 0.06);
}
body.theme-dark .zerino-assistant-input {
    background: #142539;
    border-color: rgba(255, 255, 255, 0.08);
    color: #e6edf6;
}
body.theme-dark .zerino-assistant-input:focus { background: #18293f; }
body.theme-dark .zerino-assistant-hint { color: #92a4be; }
body.theme-dark .zerino-assistant-dots span { background: #b8d5ee; }

