/* ---- Global Styles ---- */
body {
    /* Default to SF Pro (system on Apple), with common fallbacks */
    font-family: 'SF Pro Text', 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--color-bg);
    color: var(--color-text);
    margin: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    direction: ltr; /* Default to LTR, individual elements handle their own dir */
    overflow-x: hidden; /* Prevent horizontal scroll when overlay is off-screen */
}

.is-hidden {
    display: none !important;
}

/* Layout variables (responsive-friendly via clamp) */
:root {
    /* Layout */
    --content-max: 1080px;                 /* max width for main content */
    --page-pad: clamp(14px, 3vw, 24px);    /* side padding for page */
    --section-gap: clamp(16px, 4vw, 60px); /* vertical spacing between sections */
    --panel-pad: clamp(16px, 2.4vw, 24px); /* inner padding for cards/panels */
    --grid-gap: clamp(10px, 2vw, 16px);    /* gaps inside grids */
    --control-height: 46px;                /* unified control height */
    --control-height-sm: 38px;             /* small control height */
    --control-height-lg: 54px;             /* large control height */

    /* Spacing scale */
    --space-1: 2px;
    --space-2: 4px;
    --space-3: 8px;
    --space-4: 12px;
    --space-5: 16px;
    --space-6: 20px;
    --space-7: 24px;
    --space-2-5: 10px;                     /* fractional spacing */
    --space-6-5: 26px;
    --space-7-5: 30px;

    /* Radii */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-card: 10px;

    /* Color tokens */
    --color-bg: #121212;
    --color-surface: #1b1b1b;
    --color-surface-raised: #1f1f1f;
    --color-surface-strong: #262626;
    --color-border: #2a2a2a;
    --color-border-strong: #3a3a3a;
    --color-border-muted: rgba(255,255,255,0.06);
    --color-text: #e0e0e0;
    --color-text-muted: #9aa0a6;
    --color-text-soft: #c5c5c5;
    --color-text-inverse: #0f0f10;
    --color-primary: #3b82f6;
    --color-primary-hover: #2563eb;
    --color-primary-active: #1d4ed8;
    --color-primary-light: #ffffff;
    --color-primary-light-hover: #f2f2f2;
    --color-primary-light-active: #e5e5e5;
    --color-primary-light-text: #111111;
    --color-success: #22c55e;
    --color-danger: #ef4444;
    --color-warning: #facc15;

    /* Elevation */
    --shadow-soft: 0 8px 26px rgba(0, 0, 0, 0.28);
    --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 16px 32px rgba(0, 0, 0, 0.35);

    /* Typography */
    --font-size-xs: 0.5rem;
    --font-size-sm: 0.75rem;
    --font-size-base: 0.85rem;
    --font-size-md: 0.95rem;
    --font-size-lg: 1rem;
    --font-size-xl: 1.1rem;
    --font-weight-regular: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;

    /* Motion */
    --transition-base: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.18s ease;
    /* Component sizes */
    --avatar-size: 38px;
    --user-item-height: 56px;
    --status-dot-size: 10px;
    --status-dot-border: 2px;
    --menu-offset-sm: 6px;
    --border-width-1: 1px;

    /* Wizard spacing */
    --wizard-row-gap: 10px;           /* vertical gap inside a row */
    --wizard-row-margin: 14px;        /* space between rows */
    --wizard-inline-gap: 14px;        /* inline gap for radios/buttons */
    --wizard-hint-mt: 10px;           /* hint top spacing */
    --wizard-hint-mb: 16px;           /* hint bottom spacing */
    --wizard-actions-gap: 12px;       /* space between nav buttons */
}

/* (Removed global scaling overrides) */

/* === UI Kit ============================================================ */

/* Base surface + typography helpers */
.ui-surface {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--space-5);
}

.ui-heading {
    margin: 0;
    font-weight: var(--font-weight-semibold);
    color: var(--color-text);
}

.ui-text-muted {
    color: var(--color-text-muted);
}

/* Buttons --------------------------------------------------------------- */
.ui-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 0 var(--space-4);
    height: var(--control-height);
    line-height: 1;
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    background: var(--color-surface-raised);
    box-shadow: none;
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition-base);
}

.ui-btn i {
    color: inherit;
    font-size: 1em;
}

.ui-btn:hover {
    background: var(--color-surface-strong);
    border-color: var(--color-border-strong);
}

.ui-btn:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.ui-btn:active {
    transform: translateY(1px);
}

.ui-btn[disabled],
.ui-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.ui-btn--primary {
    background: var(--color-primary-light);
    border-color: rgba(17, 17, 17, 0.12);
    color: var(--color-primary-light-text);
    box-shadow: none;
}

.ui-btn--primary:hover {
    background: var(--color-primary-light-hover);
    border-color: rgba(17, 17, 17, 0.22);
}

.ui-btn--primary:focus-visible {
    outline-color: rgba(17, 17, 17, 0.35);
}

.ui-btn--primary:active {
    background: var(--color-primary-light-active);
}

.ui-btn--secondary {
    background-color: #0f0f0f !important;
    border-color: #1f1f1f !important;
    color: #f5f5f5 !important;
}

.ui-btn--secondary i {
    color: inherit;
}

.ui-btn--secondary:hover {
    background-color: #181818 !important;
    color: #ffffff !important;
    border-color: #262626 !important;
}

.ui-btn--secondary:active {
    background-color: #060606 !important;
}



.ui-btn--ghost {
    background: transparent;
    border-color: var(--color-border);
}

.ui-btn--danger {
    background: var(--color-danger);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 6px 18px rgba(239, 68, 68, 0.35);
}

.ui-btn--icon {
    width: var(--control-height);
    min-width: var(--control-height);
    height: var(--control-height);
    padding: 0;
    aspect-ratio: 1 / 1;
}

.ui-btn--icon-label {
    padding: 0 var(--space-4);
}

.ui-btn--sm {
    height: var(--control-height-sm);
    padding: 0 var(--space-3);
    font-size: var(--font-size-sm);
}

.ui-btn--sm.ui-btn--icon {
    width: var(--control-height-sm);
    min-width: var(--control-height-sm);
    height: var(--control-height-sm);
}

.ui-btn--lg {
    height: var(--control-height-lg);
    padding: 0 var(--space-5);
    font-size: var(--font-size-md);
}

.ui-btn__icon {
    font-size: 1em;
    line-height: 1;
}

.ui-btn__label {
    font-size: var(--font-size-sm);
    letter-spacing: 0.01em;
}

/* Inputs --------------------------------------------------------------- */
.ui-field {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.ui-label {
    font-size: var(--font-size-sm);
    color: var(--color-text-soft);
    font-weight: var(--font-weight-medium);
}

.ui-input {
    width: 100%;
    max-width: 100%;
    height: var(--control-height);
    padding: 0 var(--space-4);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    background: var(--color-surface-raised);
    color: var(--color-text);
    font-size: var(--font-size-base);
    /* Prefer SF Pro for Latin; use Vazirmatn for Persian/Arabic glyphs */
    font-family: 'SF Pro Text', 'SF Pro Display', 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    transition: var(--transition-base);
    box-sizing: border-box;
    min-width: 0;
    -webkit-appearance: none;
    appearance: none;
}

.ui-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.ui-input::placeholder {
    color: var(--color-text-muted);
}

.ui-input--invalid {
    border-color: var(--color-danger);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

.ui-textarea {
    min-height: calc(var(--control-height) * 2);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    background: var(--color-surface-raised);
    color: var(--color-text);
    font-size: var(--font-size-base);
    /* Prefer SF Pro for Latin; use Vazirmatn for Persian/Arabic glyphs */
    font-family: 'SF Pro Text', 'SF Pro Display', 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    resize: vertical;
    transition: var(--transition-base);
}

.ui-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

/* Chips & Badges ------------------------------------------------------- */
.ui-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    background: var(--color-surface-raised);
    border: 1px solid var(--color-border);
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

.ui-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    padding: 0 var(--space-1);
    border-radius: 999px;
    background: var(--color-primary);
    color: #fff;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
}

/* Utilities ------------------------------------------------------------ */
.ui-stack {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.ui-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.ui-divider {
    height: 1px;
    width: 100%;
    background: var(--color-border);
}

/* ---- Site Header ---- */
.site-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px 20px;
    box-sizing: border-box;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(10,10,10,0.6);
    backdrop-filter: saturate(140%) blur(8px);
    -webkit-backdrop-filter: saturate(140%) blur(8px);
}
.brand {
    font-weight: 600;
    color: #ffffff;
    letter-spacing: 0.5px;
    font-size: var(--font-size-xl);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.site-nav { display:none; }
/* Brand icon next to text */
.brand-icon {
    width: 26px;   /* slightly larger for visibility */
    height: 26px;
    display: inline-block;
    vertical-align: middle;
}

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

/* ---- Hero ---- */
.hero {
    width: 100%;
    padding: clamp(36px, 8vw, 128px) var(--page-pad) clamp(16px, 4vw, 128px);
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(1200px 400px at 50% -200px, rgba(255,255,255,0.08), rgba(0,0,0,0));
}
.hero-inner { max-width: 980px; width: 100%; text-align: center; }
/* Elevated brand chip above hero title */
.hero-brand {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 0 auto 20px;
    padding: 10px 14px;
    /* border: 1px solid rgba(255,255,255,0.12); */
     /* background: rgba(255,255,255,0.0);  */
    border-radius: var(--radius-card);
    backdrop-filter: saturate(140%) blur(6px);
    -webkit-backdrop-filter: saturate(140%) blur(6px);
    /* box-shadow: 0 8px 26px rgba(0,0,0,0.45); */
    transition: transform .18s ease, box-shadow .18s ease;
    position: relative; /* enable overlay badge positioning */
}
.hero-brand:hover { transform: translateY(-1px); box-shadow: 0 10px 30px rgba(0,0,0,0.0); }
.hero-brand-icon { width: 42px; height: 42px; display: inline-block; filter: drop-shadow(0 2px 8px rgba(255,255,255,0.12)); }
.hero-brand-name { color: #ffffff; font-weight: 600; font-size: var(--font-size-xl); letter-spacing: 0.6px; }
.hero-brand::after {
    content: 'Beta';
    position: absolute;
    top: -8px;
    right: -10px;
    padding: 2px 8px;
    font-size: 10px;
    line-height: 1.2;
    background: var(--color-primary);
    color: #fff;
    border-radius: 999px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.35);
    pointer-events: none;
}
.hero-brand-name::after {
    content: '';
    width: 6px; height: 6px; border-radius: 50%;
    margin-left: 8px;
    background: radial-gradient(#fff, rgba(255,255,255,0.05));
    box-shadow: 0 0 10px rgba(255,255,255,0.45);
    display: inline-block;
    animation: heroSpark 2.2s ease-in-out infinite;
    vertical-align: middle;
}
@keyframes heroSpark {
  0%, 100% { transform: scale(2); opacity: 0.6; }
  50% { transform: scale(1); opacity: 0.2; }
}
@media (max-width: 520px) {
  .hero-brand-icon { width: 32px; height: 32px; }
  .hero-brand-name { font-size: var(--font-size-lg); letter-spacing: 0.5px; }
  .hero-brand::after { top: -10px; right: -8px; font-size: 9px; padding: 2px 6px; }
}
.hero-title {
    margin: 0 0 10px 0;
    font-size: clamp(28px, 6vw, 56px);
    color: #fff;
    font-weight: 800;
}
.hero-sub {
    color: #bcbcbc;
    font-size: clamp(14px, 2.2vw, 18px);
    margin: 0 auto;
    max-width: 720px;
}
.hero-actions { margin-top: 32px; display: flex; gap: 12px; justify-content: center; }

/* ---- Modal ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}
.modal-overlay[hidden] { display: none !important; }
.modal {
    width: 100%;
    max-width: 560px;
    background: #1b1b1b;
    border: 1px solid #2a2a2a;
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    padding: 16px;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 8px;
    border-bottom: 1px solid #2a2a2a;
}
.modal-header h3 { margin: 0; color: #e5e5e5; font-size: var(--font-size-lg); font-weight: 600; }
.modal-close {
    background: transparent;
    color: #c9c9c9;
    border: 1px solid #3a3a3a;
    border-radius: var(--radius-card);
    padding: 8px 12px;
}
.modal-close:hover { background: #2a2a2a; color: #fff; border-color: #4a4a4a; }

.modal-form { display: flex; flex-direction: column; gap: 12px; padding-top: 12px; }
.modal-form .form-row { display: flex; flex-direction: column; gap: 6px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 8px; }
/* OTP UI */
.otp-hint { margin-top: 6px; font-size: 0.9em; color: #9aa0a6; }
.otp-hint.ok { color: #6dd36d; }
.otp-hint.warn { color: #f0c36d; }
.otp-hint.error { color: #ff8a8a; }

/* Wizard */
.stepper { display: grid; grid-template-columns: 20px 1fr 20px 1fr 20px 1fr 20px; align-items: center; gap: 8px; padding: 4px 0 14px; }
.stepper-dot { width: 20px; height: 20px; border-radius: 50%; background: #2a2a2a; color: #c9c9c9; display: flex; align-items: center; justify-content: center; font-size: 12px; border: 1px solid #3a3a3a; }
.stepper-dot.active { background: #ffffff; color: #111; border-color: #e5e5e5; }
.stepper-dot.done { background: #9aa0a6; color: #111; border-color: #bdbdbd; }
.stepper-line { height: 2px; background: #2a2a2a; border-radius: 1px; }
.wizard-step { padding-top: 2px; }
.wizard-actions { justify-content: space-between; align-items: center; }
.wizard-actions .wizard-nav { display: inline-flex; gap: var(--wizard-actions-gap); }
.wizard-hint { display: block; margin: var(--wizard-hint-mt) 0 var(--wizard-hint-mb); line-height: 1.45; }
.radio-group { display: flex; gap: var(--wizard-inline-gap); }
.radio-item { display: inline-flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid #2a2a2a; border-radius: 10px; background: #1f1f1f; }
.radio-item input { margin: 0; }
.radio-item:hover { border-color: #3a3a3a; }

/* Increase spacing between components inside wizard steps */
.wizard-step .form-row { gap: var(--wizard-row-gap); margin-bottom: var(--wizard-row-margin); }
.wizard-step .file-upload-group { gap: var(--wizard-inline-gap); }

/* Inline row helper for phone + button */
.inline-row { display: flex; gap: var(--wizard-inline-gap); width: 100%; align-items: stretch; }
.inline-row .ui-btn { height: var(--control-height); }
.wizard-step #smsOtpInput { height: var(--control-height); padding-top: 0; padding-bottom: 0; }
.wizard-step input.ui-input { height: var(--control-height); padding-top: 0; padding-bottom: 0; }

/* Title for step sections */
.wizard-title { font-weight: 700; color: #e5e5e5; font-size: var(--font-size-lg); }

/* (removed generic helper text style) */

/* Prefer Vazirmatn for Persian (and general RTL content in this app) */
:lang(fa), [lang="fa"], [dir="rtl"] {
    font-family: 'Vazirmatn', 'SF Pro Text', 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', Tahoma, Arial, sans-serif;
}

/* ---- Footer ---- */
.site-footer { margin-top: auto; width: 100%; display: flex; justify-content: center; padding: 18px 20px; color: #979797; font-size: 0.95em; font-weight: 360; border-top: 1px solid rgba(255,255,255,0.06); background: rgba(10,10,10,0.5); backdrop-filter: saturate(140%) blur(6px); }
.footer-inner { width: 100%; max-width: 1080px; text-align: center; }

/* ---- Page Header ---- */
.room-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #333; /* separator only */
    box-sizing: border-box;
}
.header-left { display: flex; flex-direction: column; gap: 6px; }
.service-name {
    font-weight: 600;
    font-size: var(--font-size-xl);
    color: #ffffff;
    display: inline-flex;       /* align icon + text on one baseline */
    align-items: center;        /* vertical centering */
    gap: 8px;                   /* space between icon and name */
}
@keyframes spin { to { transform: rotate(360deg); } }
/* Keep default color; only spin icon during connecting */
.service-name.connecting .brand-icon { animation: spin 1.1s linear infinite; }
.room-title { font-weight: 500; font-size: var(--font-size-md); color: #9aa0a6; }
.header-right { display: flex; align-items: center; gap: 8px; }

/* Icon buttons for header (legacy alias to UI kit) */
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 0 var(--space-4);
    height: var(--control-height);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border-strong);
    background: var(--color-surface);
    color: var(--color-text);
    font-weight: var(--font-weight-semibold);
    cursor: pointer;
    transition: var(--transition-base);
}
.icon-btn:hover {
    background: var(--color-surface-strong);
    color: #fff;
    border-color: var(--color-border-strong);
}
.icon-btn i { font-size: 1em; color: inherit; }
.icon-btn.with-label span { font-size: var(--font-size-sm); }
/* Smaller variant for compact header controls */
.icon-btn.small { height: var(--control-height-sm); padding: 0 var(--space-3); font-size: var(--font-size-sm); }

/* Base styles for inputs and buttons, overridden by more specific classes */
input:not(.ui-input), button:not(.ui-btn) {
    padding: var(--space-3);
    /* Removed margin: 5px; to allow for more controlled spacing within forms */
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    background-color: var(--color-surface);
    color: var(--color-text);
    font-size: var(--font-size-base);
    transition: var(--transition-base);
    box-sizing: border-box;
    max-width: 100%;
}

input:not(.ui-input)::placeholder {
    color: var(--color-text-muted);
}

/* General input focus style for consistency */
input:not(.ui-input):focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}

/* General button styles, overridden by more specific classes */
button:not(.ui-btn) {
    background-color: var(--color-surface-raised);
    border: 1px solid var(--color-border);
    cursor: pointer;
    border-radius: var(--radius-md);
    box-shadow: none;
}

button:not(.ui-btn):hover {
    background-color: var(--color-surface-strong);
}

button:not(.ui-btn):active {
    transform: translateY(1px);
}

/* Removed global width for text inputs */
/* input[type="text"] { width: 90%; } */

/* ---- Main Container for Auth Page ---- */
.main-container {
    display: flex;
    flex-direction: column; /* Stack hero above content */
    justify-content: flex-start; /* Start at the top of the page */
    align-items: stretch; /* Let children span full width by default */
    flex: 1 0 auto; /* fill remaining height so footer sticks to bottom */
    background: linear-gradient(135deg, #131313, #0a0a0a); /* Subtle gradient background */
    padding: 0 var(--page-pad) var(--section-gap); /* responsive side/bottom padding */
    box-sizing: border-box;
    position: relative; /* anchor top glow overlay */
}

/* Subtle top glow overlay independent of header */
.main-container::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 480px;
    background: radial-gradient(1100px 600px at 50% -160px, rgba(255, 255, 255, 0.12), rgba(0,0,0,0));
    pointer-events: none;
    z-index: 5; /* above contents like warning bar, but non-interactive */
}

/* Compatibility warning bar */
.compat-warning {
    width: fit-content;
    max-width: var(--content-max);
    margin: 12px auto 0;
    border: 1px solid #e5e5e5;
    background: #ffffff;        /* eye-catching white bar */
    color: #111;                /* dark text for contrast */
    border-radius: 10px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.25);
}
.compat-warning[hidden] { display: none !important; }
.compat-warning .warning-text {
    font-size: 0.98em;
    line-height: 1.35;
    font-weight: 500;
    flex: 1 1 auto;
}
/* Warning icon next to text */
.compat-warning .warning-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    color: #111; /* icon uses currentColor in SVG */
    line-height: 0;          /* remove baseline gap */
    flex: 0 0 auto;          /* prevent stretch */
    margin-right: 0;         /* gap handled by flex gap */
}
.compat-warning .warning-icon svg { display: block; }
.compat-warning .compat-close {
    border: none;
    background: rgba(0,0,0,0.05);
    color: inherit;
    font-size: 0.95em;
    font-weight: 600;
    line-height: 1;
    border-radius: 999px;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-left: 8px;
    transition: background 0.2s ease;
}
.compat-warning .compat-close:hover,
.compat-warning .compat-close:focus {
    background: rgba(0,0,0,0.12);
    outline: none;
}
.compat-warning .compat-close:focus-visible {
    outline: 2px solid rgba(0,0,0,0.4);
    outline-offset: 2px;
}

/* ---- Auth Card (formerly .center-box) ---- */
.compat-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    margin: 4px 0 8px;
    border-radius: 8px;
    background: rgba(250, 204, 21, 0.08); /* subtle amber */
    border: 1px solid rgba(250, 204, 21, 0.22);
    color: #facc15;
    font-size: 0.9em;
}
.compat-inline[hidden] { display: none !important; }
.compat-inline .warning-icon { width: 16px; height: 16px; color: #facc15; }
.compat-inline .warning-text { color: #e8e2c0; font-weight: 500; }

.auth-card {
    width: 100%;
    padding: var(--panel-pad); /* Consistent panel padding */
    border: 1px solid #262626; /* Subtle border */
    border-radius: 12px; /* Softer corners */
    background: rgba(30,30,30,0.9);
    box-shadow: 0 10px 30px rgba(0,0,0,0.6);
    text-align: left;
    display: flex;
    flex-direction: column; /* For equal-height pairing */
    /* card uses global control height */
}
/* Wider layout for the create and rooms panels */
.create-card { width: 100%; margin: 0; }
.rooms-card  { width: 100%; margin: 0; }

/* ---- Landing Layout ---- */
.landing-container {
    display: flex;
    flex-direction: column;
    gap: var(--section-gap);
    width: 100%;
    max-width: var(--content-max);
    margin: var(--section-gap) auto 0; /* Center under hero */
}
/* Ensure the full-width cards expand to container edges */
.landing-container > .auth-card.create-card { align-self: stretch; width: 100%; }

/* no grid breakpoint needed when stacked */

/* ---- Features (separate cards matching panel weight) ---- */
.features {
    width: 100%;
    max-width: var(--content-max);
    margin: var(--section-gap) auto 0; /* align with other panels */
}
.features-grid { width: 100%; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 320px)); justify-content: center; gap: var(--grid-gap); padding: 0; box-sizing: border-box; }
.feature-item {
    /* Grid items auto-size to track width */
    border: 1px solid #262626;
    /*background: rgba(30,30,30,0.9);*/
    border-radius: 10px;
    padding: var(--panel-pad);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
}
/* Auto-fit grid handles responsiveness; no extra media queries needed */
.feature-icon { font-size: var(--font-size-lg); opacity: 0.9; }
.feature-title { font-weight: 700; color: #ffffff; }
.feature-text { color: #9aa0a6; font-size: 0.95em; }

/* ---- How-To Section ---- */
.howto {
    width: 100%;
    max-width: var(--content-max);
    margin: var(--section-gap) auto 0;
}
.howto-video {
    width: 100%;
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: var(--radius-card);
    border: 1px solid #2a2a2a;
    background: #0f0f0f;
}

.rooms-card {
    width: 100%;
    padding: 0px;
    border: 1px solid #262626;
    border-radius: 12px;
    /* background: rgba(30,30,30,0.9);*/
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column; /* For equal-height pairing */
}
.rooms-header { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 16px; align-items: stretch; text-align: left; border-bottom: 1px solid #2a2a2a; }
.rooms-card h2 { color: #e5e5e5; margin: 0; font-size: var(--font-size-lg); font-weight: 600; }
.rooms-subtitle { color: #9aa0a6; font-size: 0.95em; }

.rooms-grid {
    display: grid; /* grid of cards */
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--grid-gap);
    margin: 16px;
}
@media (max-width: 980px) { .rooms-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .rooms-grid { grid-template-columns: 1fr; } }

.room-card {
    border: 1px solid #2a2a2a;
    /* background: #161616; */
    border-radius: 10px;
    padding: 16px 18px;
    display: flex;           /* vertical card layout */
    flex-direction: column;
    gap: 6px;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.room-thumb { width: 100%; aspect-ratio: 16/9; background: #0f0f0f; border-radius: var(--radius-card); overflow: hidden; border: 1px solid #222; }
.room-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.room-card:hover { border-color: #3a3a3a; box-shadow: 0 6px 16px rgba(0,0,0,0.35); }

/* ---- FAQ ---- */
.faq {
    width: 100%;
    max-width: var(--content-max);
    margin: var(--section-gap) auto 0;
}
.faq-card {
    width: 100%;
    padding: 0;
    border: 1px solid #262626;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
}
.faq-header { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 16px; align-items: stretch; text-align: left; border-bottom: 1px solid #2a2a2a; }
.faq-card h2 { color: #e5e5e5; margin: 0; font-size: var(--font-size-lg); font-weight: 600; }
.faq-subtitle { color: #9aa0a6; font-size: 0.95em; }
.faq-list { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px 18px; }
.faq-item {
    border: 1px solid #2a2a2a;
    border-radius: var(--radius-card);
    background: transparent;
    overflow: hidden;
}
.faq-summary {
    list-style: none;
    cursor: pointer;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #e6e6e6;
    font-weight: var(--font-weight-regular);
    user-select: none;
}
.faq-summary::-webkit-details-marker { display: none; }
.faq-summary::after {
    content: '\25BE'; /* small down triangle */
    color: #bcbcbc;
    transition: transform 0.18s ease;
    margin-left: 12px;
}
.faq-item[open] .faq-summary::after { transform: rotate(180deg); }
.faq-item[open] .faq-summary { border-bottom: 1px solid #2a2a2a; }
.faq-content {
    padding: 12px 16px 16px;
    color: #9aa0a6;
    line-height: 1.6;
}

.room-title-line {
    color: #e6e6e6;
    font-weight: 700;
    font-size: 1.05em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.room-meta { color: #b0b0b0; font-size: 0.9em; }
.room-stats { color: #9aa0a6; font-size: 0.9em; display: flex; align-items: center; gap: 6px; }
.room-stats .sep { opacity: .6; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.online { background: #3ddc84; }

/* Make links/buttons clearly focusable for keyboard users */
.join-button:focus-visible, .custom-file-upload:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255,255,255,0.35);
}

.room-actions { display: flex; gap: 8px; margin-top: 6px; justify-content: flex-end; }
.join-button {
    text-decoration: none;
    background: rgba(255, 255, 255, 0.065); /* primary switched to white */
    color: #ffffff;
    padding: 10px 12px;
    border-radius: 10px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, transform 0.08s ease;
}
.join-button:hover { background: #ffffff; color: #111; }
.join-button:active { transform: translateY(1px); }

.auth-card h2 {
    margin: 0; /* match room headers */
    color: #e5e5e5;
    font-size: var(--font-size-lg);
    font-weight: 600;
    padding: 0; /* align with card padding */
}

.auth-card .tagline {
    color: #9aa0a6; /* like room subtext */
    font-size: 0.95em;
    margin: 6px 0 0; /* close to title */
    line-height: 1.4;
    text-align: left;
    padding: 0 0 12px; /* bottom spacing for divider */
    border-bottom: 1px solid #2a2a2a; /* match room section header divider */
}

/* Styles for the form within auth-card */
.auth-card .create-room-form {
    display: grid;
    /* name | url | file | submit */
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 2fr) fit-content(220px) fit-content(160px);
    gap: var(--grid-gap);
    align-items: stretch;
    padding: 0;
}
/* Prevent grid children from causing horizontal overflow */
.auth-card .create-room-form > * { min-width: 0; }
/* Responsiveness for the create form */
@media (max-width: 1100px) {
    .auth-card .create-room-form { grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr) fit-content(200px) fit-content(140px); }
    /* Move file upload below on medium widths */
    .auth-card .file-upload-group { grid-column: 1 / -1; }
}
@media (max-width: 900px) {
    /* Collapse to three columns: name | url | submit; file spans next row */
    .auth-card .create-room-form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) fit-content(150px); }
    .auth-card .file-upload-group { grid-column: 1 / -1; }
}
@media (max-width: 700px) {
    .auth-card .create-room-form { grid-template-columns: 1fr; }
}

.auth-card .form-group {
    width: 100%; /* Make form groups take full width */
    display: flex;
    flex-direction: column;
    align-items: flex-start; /* Align labels/inputs to the left within group */
    /* No padding here. Inputs/buttons will have their own internal padding. */
    box-sizing: border-box; /* Include padding in width calculation */
}

.auth-card .form-group input[type="text"] {
    width: 100%; /* Text inputs fill the form-group width */
    margin-bottom: 0; /* Ensure no extra margin below text inputs */
    padding: 0 14px; /* Horizontal padding; vertical derives from height */
    height: var(--control-height);
    border-radius: var(--radius-card); /* Consistent with index page radius */
    background-color: #2a2a2a; /* Slightly darker input background */
    border: 1px solid #3a3a3a; /* Subtle input border */
    box-sizing: border-box; /* Ensures padding is included in the 100% width */
    text-align: left; /* Keep input text readable when parent is centered */
}
/* Index-only: white focus accent */
.auth-card .form-group input[type="text"]:focus {
    border-color: #ffffff;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.25);
}

/* URL input visuals to match text */
.auth-card .form-group input[type="url"] {
    width: 100%;
    padding: 0 14px;
    height: var(--control-height);
    border-radius: var(--radius-card);
    background-color: #2a2a2a;
    border: 1px solid #3a3a3a;
    box-sizing: border-box;
    text-align: left; /* Keep input text readable when parent is centered */
}
.auth-card .form-group input[type="url"]:focus {
    border-color: #ffffff;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.25);
}

/* Custom styling for the file upload button */
.custom-file-upload {
    display: inline-flex; /* Align text vertically */
    align-items: center;
    padding: 0 14px; /* Match input horizontal padding */
    height: var(--control-height);
    cursor: pointer;
    background-color: #444; /* Secondary, darker color */
    color: #e0e0e0;
    border-radius: var(--radius-card); /* Consistent corner radius */
    border: 1px solid #3a3a3a; /* Match input border for equal visual height */
    transition: background-color 0.3s ease, box-shadow 0.3s ease, transform 0.1s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    font-size: 1em;
    text-align: center;
    width: auto; /* shrink to fit, but clamp with max-width */
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0; /* Inline layout */
    box-sizing: border-box; /* Ensures padding is included in the 100% width */
}

.custom-file-upload:hover {
    background-color: #555; /* Darker hover for the new color */
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.custom-file-upload:active {
    transform: translateY(1px);
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

/* Hide the actual file input (works for both index form and modal) */
.form-group input[type="file"],
.file-upload-group input[type="file"],
.modal-form input[type="file"] {
    display: none;
}

.file-upload-group { display: flex; align-items: center; gap: 10px; }
.file-name {
    font-size: 0.85em; /* Slightly smaller font for file name */
    color: #9aa0a6;
    text-align: left; /* Align file name to the left */
    width: 100%;
    word-break: break-all; /* Prevent overflow for long file names */
    padding: 0; /* compact when inline with button */
    box-sizing: border-box; /* Ensures padding is included in the 100% width */
}
.file-name:empty { display: none; }

/* ---- Notifications Bar (Removed) ---- */
/* The .notifications-bar styles have been removed as the element is no longer in room.html */

/* User List Toggle button (now just a display) - This style block is kept but the element is removed in HTML */
.user-list-toggle {
    padding: 5px 10px;
    border-radius: var(--radius-card);
    background-color: #2a2a2a;
}


/* ---- Room Layout (Two Main Columns) ---- */
.room-container {
    display: flex; /* Main container is flex row */
    flex-direction: row;
    flex: 1;
    /* Allow body flex to allocate remaining space below header */
    min-height: 0;
    padding: 0px;
    box-sizing: border-box;
    gap: 0px; /* Gap between video and right column wrapper */
    overflow: hidden;
}

.video-section {
    flex: 3; /* Video section takes more flexible space (e.g., 3 units) */
    padding: 0px;
    padding-bottom: 0px; /* Added padding to the bottom of the video player box */
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    background-color: black;
    border-radius: 0px; /* Balanced corner radius */
    box-shadow: 0 4px 12px rgba(0,0,0,0.7);
    border: 1px solid #333; /* Added border to the video section */
    position: relative; /* Anchor tap-to-play overlays */
}

/* Ensure the video element fills its container */
.video-section video {
    width: 100%;
    height: 100%;           /* fill the container height */
    object-fit: contain;    /* keep entire frame visible */
}

/* Right Column Wrapper (contains user list panel and chat) */
.right-column-wrapper {
    flex: 1; /* Takes less flexible space (e.g., 1 unit) to decrease width by 1/4 relative to video */
    display: flex;
    flex-direction: column; /* Stacks its children (panel & chat) vertically */
    gap: 0px; /* Gap between user list panel and chat section */
    height: 100%;
    min-height: 0; /* allow children to shrink within available height */
    overflow: hidden; /* prevent children from overflowing vertically */
}

/* --- Mobile Tabs (hidden on desktop) --- */
.mobile-tabs {
    display: none;
}
.mobile-tabs .tab-btn {
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    color: #e0e0e0;
    padding: 10px 12px;
    border-radius: 0px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 600;
}
.mobile-tabs .tab-btn.active {
    background: #1e1e1e;
}

.chat-section {
    display: flex;
    flex-direction: column;
    /*background-color: #1e1e1e;
    border-radius: 0ch; /* Balanced corner radius */
    /* Take the remaining space and contain its own overflow */
    flex: 1 1 0;
    position: relative;
    border-left: none;
    margin-left: 0;
    padding: 0px; /* Added internal padding to the chat section */
    border: 1px solid #333; /* Added border to the chat section */
    min-height: 0; /* Allows the flex item to shrink below its content size */
    overflow: hidden; /* ensure inner scrollers handle overflow */
}

/* Chat header (mirrors participants header style) */
.chat-header {
    display: flex;
    flex-direction: column;
    justify-content: center; /* center children vertically */
    gap: var(--space-2-5);
    padding: var(--space-5) var(--space-5); /* symmetric vertical padding for visual centering */
    border-bottom: var(--border-width-1) solid #2a2a2a;
    position: relative; /* allow absolute-positioned dropdown */
}
.chat-title { margin: 0; color: #e5e5e5; font-size: var(--font-size-lg); font-weight: 600; }
.chat-sub { color: #9aa0a6; font-size: var(--font-size-sm); }
/* Top row: title and mute button */
.chat-header-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chat-header-text { display: flex; flex-direction: column; gap: 6px; }

/* Chat header dropdown menu */
.chat-menu {
    position: absolute;
    top: calc(100% + var(--menu-offset-sm)); /* below header */
    right: var(--space-5);
    background: #1e1e1e;
    border: var(--border-width-1) solid #333;
    border-radius: var(--radius-card);
    padding: var(--space-3);
    min-width: 240px; /* keep absolute width for layout consistency */
    box-shadow: 0 10px 24px rgba(0,0,0,0.45);
    z-index: 60;
}
.chat-menu .menu-item {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 8px 6px;
    border-radius: 8px;
    cursor: pointer;
    color: #e0e0e0;
}
.chat-menu .menu-item:hover { background: #2a2a2a; }
.chat-menu .menu-item input[type="checkbox"] { margin-top: 2px; }
.chat-menu .menu-text { display: flex; flex-direction: column; }
.chat-menu .menu-title { font-size: var(--font-size-base); }
.chat-menu .menu-desc { font-size: var(--font-size-sm); color: #9aa0a6; }

/* User List Panel (inside right-column-wrapper, above chat) */
.user-list-panel {
    /*background-color: #1e1e1e;
    border-radius: 0px; /* Balanced corner radius */
    padding: 0px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    max-height: none; /* let the header+list define the panel height */
    flex: 0 0 auto; /* keep panel at content height; don't let it be overlapped */
    border: 1px solid #2a2a2a; /* subtle container border */
    /* Make header fixed and only the list scrolls */
    display: flex;
    flex-direction: column;
    overflow: hidden; /* prevent the panel itself from scrolling */
    min-height: 0; /* allow flex children to shrink */
}

.user-list-header {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px; /* preserve original spacing */
    margin: 0px;
    padding: var(--space-5) var(--space-5);
    border-bottom: var(--border-width-1) solid #2a2a2a;
}

/* Participants header row: text group + chevron button */
.user-list-header-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.user-list-header-text { display: flex; flex-direction: column; gap: 6px; }

.user-list-panel h4 {
    margin: 0px;
    color: #e5e5e5;
    font-size: var(--font-size-lg);
    text-align: left;
    font-weight: 600;
}

.user-list-sub { color: #9aa0a6; font-size: var(--font-size-sm); }

/* Participant list typography and badges */
.user-avatar-letter { text-transform: uppercase; opacity: 0.95; }
.user-content { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.user-top-row { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.user-sub { color: #9aa0a6; font-size: var(--font-size-sm); }
.crown-icon { color: #ffd54f; font-size: var(--font-size-sm); }
.chip { background: #333a; color: #ddd; border-radius: 10px; padding: 2px 6px; font-size: var(--font-size-xs); font-weight: 600; }

.active-user-list-panel {
    border: none;
    border-radius: 0;
    list-style: none;
    padding: 0px;
    display: flex;
    flex-direction: column;
    margin-top: 0px;
    margin-bottom: 0px;
    overflow-y: auto; /* scroll only the list */
    flex: 1 1 auto;   /* take remaining height in the panel */
    min-height: 0;    /* allow shrinking within flex parent */
    gap: 0;           /* we'll separate with borders */
    /* Show exactly 3 items; list itself scrolls */
    --user-item-h: var(--user-item-height);
    box-sizing: border-box;
    height: calc(var(--user-item-h) * 3.5 + var(--space-3) + (var(--border-width-1) * 2)); /* items + vertical padding + 2 dividers */
}

/* Collapsed participants: hide the list, keep header visible */
.user-list-panel.collapsed .active-user-list-panel { display: none; }

.user-list-item {
    display: flex;
    justify-content: flex-start; /* keep content grouped; controls push right */
    align-items: center;
    padding: var(--space-7-5) var(--space-5);
    background-color: transparent;
    transition: background-color 0.15s ease;
    position: relative;
    overflow: hidden;
    gap: 8px;
    height: var(--user-item-h);
    flex: 0 0 var(--user-item-h); /* lock row height; prevent shrinking */
    box-sizing: border-box;
}

.user-list-item:hover { background-color: #232323; }

.user-list-item + .user-list-item { border-top: 1px solid #232323; }

/* NEW: User Avatar Circle */
.user-avatar {
    width: var(--avatar-size); /* Diameter of the circle */
    height: var(--avatar-size);
    border-radius: 50%; /* Make it circular */
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.9em; /* Size of the letter */
    font-weight: bold;
    color: #ffffff; /* White letter color */
    flex-shrink: 0; /* Prevent shrinking */
    margin-right: 8px; /* Space between avatar and name */
    text-transform: uppercase; /* Ensure letter is uppercase */
}

.user-name {
    display: contents;
    font-weight: 600;
    color: #e6e6e6;
    font-size: var(--font-size-base);
    min-width: 0;
    flex: 1 1 auto; /* allow name to shrink so badges are visible */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Presence status dot and latency */
.status-dot { width: var(--status-dot-size); height: var(--status-dot-size); border-radius: 50%; position: absolute; left: 40px; bottom: var(--space-3); border: var(--status-dot-border) solid #1e1e1e; }

.user-rtt {
    margin-left: 6px;
    color: #9aa0a6;
    font-size: 0.8em;
    min-width: 40px;
    white-space: nowrap;
}

.user-list-badge {
    background-color: rgba(255, 255, 255, 0.08); /* neutral badge bg */
    color: #e0e0e0; /* neutral text */
    font-size: 0.65em;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 14px;
    flex-shrink: 0;
}

.user-controls {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
    margin-left: auto; /* push controls to the far right */
}
.user-list-item:hover .user-controls { opacity: 1; }

.control-button {
    background: none;
    border: none;
    padding: 4px;
    border-radius: var(--radius-card);
    font-size: 1.0em;
    transition: background-color 0.2s, color 0.2s;
    color: #b0b0b0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.control-button:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
}

.transfer-button i {
    font-size: 0.9em;
    margin: 0;
}

/* Chat messages container styling */
.chat-messages {
    flex: 1; /* Allows it to grow and shrink */
    overflow-y: auto; /* Enables vertical scrolling */
    padding: 14px;
    background-color: #151515;
    border-radius: 0px; /* Balanced corner radius */
    gap: 10px;
    scroll-behavior: smooth;
    min-height: 0; /* Important for flex items to shrink below content size */
}

/* Wrapper for message bubble and reply/react buttons */
.chat-message-row {
    display: flex;
    align-items: flex-start;
    gap: 5px;
    position: relative;
    max-width: 100%;
    flex-wrap: wrap;
    padding-bottom: 30px;
}

/* Alignment for self messages (row) */
.chat-message-row-self {
    align-self: flex-end;
    flex-direction: row-reverse;
    margin-left: auto;
    margin-right: 0;
}

/* Alignment for other messages (row) */
.chat-message-row-other {
    align-self: flex-start;
    flex-direction: row;
    margin-right: auto;
    margin-left: 0;
}

/* Individual chat message styling (common to all messages) */
.chat-message {
    padding: 10px 14px;
    border-radius: 16px; /* More rounded chat bubbles */
    word-wrap: break-word;
    max-width: 80%;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    line-height: 1.6;
}

/* Styling for messages from the current user */
.chat-message-self {
    background-color: #838383;
    color: #ffffff;
    border-bottom-right-radius: 2px;
}

/* Styling for messages from other users */
.chat-message-other {
    background-color: #262626;
    color: #e0e0e0;
    border-bottom-left-radius: 2px;
}

/* Header for username and timestamp */
.chat-message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
    font-size: 0.9em;
}

/* Username styling */
.chat-username {
    font-weight: bold;
    margin-right: 64px;
    white-space: nowrap;
}

/* Host badge styling (for chat messages) */
.host-badge {
    background-color: rgba(51, 51, 51, 0.102);
    color: #ffffff;
    font-size: 0.65em;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: var(--radius-card);
    margin-left: 6px;
    vertical-align: middle;
    display: inline-block;
}

/* User-list host badge chip in dark theme (override chat badge look) */
.user-name .host-badge.user-list-badge {
    background-color: rgba(255, 255, 255, 0.08);
    color: #e0e0e0;
    border-radius: 14px;
}

/* Timestamp styling */
.chat-timestamp {
    font-size: 0.7em;
    color: #dedede;
}

/* Message text styling */
.chat-text {
    margin: 0;
    padding: 0;
}

/* Sticker image shown when users send special trigger (e.g., "meow") */
.chat-sticker {
    display: block;
    max-width: 180px;
    max-height: 180px;
    width: 160px;
    height: auto;
    border-radius: 12px;
    object-fit: contain;
}

/* Chat Notification Styling */
.chat-notification {
    align-self: center;
    text-align: center;
    max-width: 70%;
    /* background-color: #282828; */
    color: #b0b0b0;
    font-size: 0.85em;
    padding: 8px 12px;
    border-radius: var(--radius-card);
    margin: 5px auto;
    box-shadow: none;
    opacity: 0.9;
}

.chat-notification .notification-timestamp {
    display: block;
    font-size: 0.7em;
    color: #888;
    margin-bottom: 3px;
}

.chat-notification .notification-text {
    margin: 0;
    font-weight: normal;
}

/* Reply Preview Area */
.reply-preview-area {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #2a2a2a;
    padding: 10px 15px;
    border-top-left-radius: 12px; /* Balanced corner radius */
    border-top-right-radius: 12px; /* Balanced corner radius */
    border-bottom: 1px solid #333;
    margin-top: auto;
}

.reply-preview-content {
    flex-grow: 1;
    padding-right: 10px;
    overflow: hidden;
}

.reply-preview-username {
    font-weight: bold;
    color: #00bcd4;
    font-size: 0.9em;
    display: block;
    margin-bottom: 2px;
}

.reply-preview-message {
    font-size: 0.8em;
    color: #b0b0b0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}

.cancel-reply-button {
    background: none;
    border: none;
    color: #e0e0e0;
    font-size: 1.2em;
    cursor: pointer;
    padding: 5px;
    margin: 0;
    border-radius: 10px;
    transition: background-color 0.2s;
}

.cancel-reply-button:hover {
    background-color: #444;
}

/* Quoted message inside a chat bubble */
.chat-replied-to {
    background-color: rgba(0, 0, 0, 0.2);
    border-left: 3px solid #00bcd4;
    padding: 8px 10px;
    margin-bottom: 8px;
    border-radius: 12px; /* Balanced corner radius */
    font-size: 0.85em;
    opacity: 0.9;
}

/* Styling for the username within the quoted reply */
.chat-replied-to .replied-to-username {
    font-weight: bold;
    color: #00bcd4;
    display: block;
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-replied-to .replied-to-text {
    color: #c0c0c0;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Reply and React buttons on individual messages (outside bubble) */
.reply-button, .react-button {
    background: none;
    border: none;
    color: #b0b0b0;
    font-size: 1.1em;
    cursor: pointer;
    padding: 6px 8px;
    margin: 0;
    border-radius: 10px;
    opacity: 0;
    transition: opacity 0.2s, background-color 0.2s, transform 0.2s;
    line-height: 1;
    flex-shrink: 0;
}

/* Show buttons on hover of the entire message row */
.chat-message-row:hover .reply-button,
.chat-message-row:hover .react-button {
    opacity: 1;
    background-color: rgba(255, 255, 255, 0.1);
}

/* Input/Send message area */
.chat-box {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4);
    border-top: 1px solid var(--color-border);
}

.chat-box input {
    flex: 1;
}

.chat-box .chat-emoji-btn {
    min-width: var(--control-height);
}

.reply-button i, .react-button i {
    font-size: 0.8em;
    color: #b0b0b0;
}

/* Emoji Picker Styling */
.emoji-picker {
    position: absolute;
    z-index: 2000; /* ensure overlay above input and bubbles */
    background-color: #2a2a2a;
    border: 1px solid #333;
    border-radius: 8px; /* Balanced corner radius */
    padding: 8px;
    display: grid;
    grid-template-columns: repeat(6, 44px);
    grid-auto-rows: 44px;
    gap: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    width: calc(44px * 6 + 6px * 5);
    min-width: calc(44px * 6 + 6px * 5);
    max-width: calc(100vw - 32px);
}

.emoji-button {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    padding: 4px;
    margin: 0;
    border-radius: 10px; /* Consistent button radius */
    transition: background-color 0.2s;
    line-height: 1;
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.emoji-button:hover {
    background-color: #3e3e3e;
}

.chat-emoji-picker {
    right: 16px;
    bottom: 80px;
    max-width: none;
}

@media (max-width: 460px) {
    .emoji-picker {
        grid-template-columns: repeat(5, 40px);
        grid-auto-rows: 40px;
        width: calc(40px * 5 + 3px * 4);
        min-width: calc(40px * 5 + 3px * 4);
    }
}

/* Reactions Container (now a flex item within chat-message-row) */
.reactions-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
    margin-top: 8px;
    padding: 0 5px;
    z-index: 1;
    justify-content: flex-start;
}

/* Adjust reactions container for self messages */
.chat-message-row-self .reactions-container {
    justify-content: flex-end;
}


/* Individual reaction bubble styling */
.reaction-bubble {
    background-color: rgba(255, 255, 255, 0.15);
    padding: 4px 8px;
    border-radius: 16px;
    font-size: 0.8em;
    color: #e0e0e0;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s;
}

.reaction-bubble:hover {
    background-color: rgba(255, 255, 255, 0.25);
}

.reaction-bubble span {
    margin-left: 3px;
    font-weight: bold;
}

/* Custom Modal for Confirmations (e.g., Transfer Host) */
.custom-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000; /* Ensure it's above other elements */
}

.modal-content {
    background-color: #1e1e1e;
    padding: 30px;
    border-radius: 14px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    text-align: center;
    max-width: 350px;
    width: 90%;
    color: #e0e0e0;
}

.modal-content p {
    margin-bottom: 20px;
    font-size: 1.1em;
    font-weight: 500;
}

.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.modal-button {
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.1s ease;
}

.modal-button.confirm {
    background-color: #ffffff; /* neutral confirm */
    color: #111;
    border: 1px solid transparent;
}

.modal-button.confirm:hover {
    background-color: #e6e6e6;
    transform: translateY(-1px);
}

.modal-button.cancel {
    background-color: #444;
    color: #e0e0e0;
    border: 1px solid #555;
}

.modal-button.cancel:hover {
    background-color: #555;
    transform: translateY(-1px);
}


/* ---- Responsive ---- */
@media (max-width: 768px) {
    body {
        overflow-x: hidden;
    }
    .room-container {
        flex-direction: column; /* Stack columns vertically on small screens */
        align-items: stretch;    /* ensure full width panels on mobile */
        height: auto;
        padding: 0px;
        gap: 0px; /* Space between stacked sections */
    }
    .video-section { max-height: 30vh; }
    .video-section,
    .right-column-wrapper { /* Right column wrapper takes full width */
        width: 100%;
        margin: 0;
        height: auto;
    }
    .right-column-wrapper {
        flex-direction: column; /* Stack panel and chat within wrapper */
        gap: 0px;
    }
    /* Show mobile tabs and arrange as two equal buttons */
    .mobile-tabs {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0px;
        padding: 0px;
        background: rgba(10,10,10,0.5);
        backdrop-filter: saturate(140%) blur(6px);
        -webkit-backdrop-filter: saturate(140%) blur(6px);
        position: sticky;
        top: 0; /* keep visible when scrolling panels under it */
        z-index: 25;
    }

    /* Hide both panels by default in mobile; show only the active one */
    .right-column-wrapper .user-list-panel,
    .right-column-wrapper .chat-section { display: none; }
    .right-column-wrapper .user-list-panel.active,
    .right-column-wrapper .chat-section.active {
        display: flex;        /* flex so inner content can fill */
        flex: 1 1 auto;       /* occupy remaining below the tabs */
        min-height: 0;        /* allow inner scroll areas */
        overflow: auto;       /* scroll inside the active panel */
    }
    /* Participants panel layout to enable internal scroll */
    .user-list-panel.active { flex-direction: column; }
    .active-user-list-panel { flex: 1 1 auto; min-height: 0; overflow: auto; }

    /* Removed .notifications-bar styles, so no need for this block */
    /*
    .notifications-bar {
        flex-direction: column;
        align-items: flex-start;
    }
    */
    .chat-message {
        max-width: 90%;
    }
    .chat-notification {
        max-width: 90%;
    }
    /* Adjust button sizes for smaller screens */
    .reply-button, .react-button {
        font-size: 0.9em;
        padding: 3px;
    }
    .reply-button i, .react-button i {
        font-size: 0.7em;
    }
    .emoji-picker {
        padding: 5px;
        gap: 3px;
        grid-template-columns: repeat(5, 40px);
        grid-auto-rows: 40px;
        width: calc(40px * 5 + 3px * 4);
        min-width: calc(40px * 5 + 3px * 4);
    }
    .emoji-button {
        font-size: 1.2em;
        padding: 3px;
        width: 40px;
        height: 40px;
    }
    .reactions-container {
        margin-top: 5px;
        padding: 0 3px;
        gap: 5px;
    }
    /* User list panel mobile adjustments */
    .user-list-panel {
        padding: 10px;
        margin: 0; /* allow full-height fill */
    }
    .user-list-panel h4 {
        margin-bottom: 8px;
    }
    .user-list-item {
        /* Keep a compact single-row layout on mobile */
        flex-direction: row;
        align-items: center;
        gap: 8px;
        padding: 6px 8px;
        height: var(--user-item-h);
        flex: 0 0 var(--user-item-h);
    }
    /* Do not stretch rows; keep fixed height */
    .active-user-list-panel.few > .user-list-item {
        flex: 0 0 var(--user-item-h);
        height: var(--user-item-h);
    }
    /* Ensure the participants list fills the panel and scrolls */
    .active-user-list-panel {
        height: auto !important;
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
    }
    .user-controls {
        width: auto;                 /* keep controls inline */
        justify-content: flex-end;
        opacity: 1;                  /* always visible on touch devices */
        margin-left: auto;           /* push to the far right */
    }
    .control-button {
        flex-grow: 1;
        text-align: center;
        padding: 6px 10px;
        font-size: 0.8em;
    }
    .control-button i {
        margin-right: 3px;
        font-size: 0.8em;
    }
}

#tapToPlay.hidden{opacity:0;pointer-events:none;transition:opacity .2s;}

/* === Tap-to-Play overlay === */
.tap-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  background: rgba(0,0,0,0.35);
  z-index: 20;
}
.tap-overlay.hidden { display: none; }

.tap-overlay-card {
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  background: rgba(20,20,20,0.75);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 18px;
  padding: 16px 18px;
  text-align: center;
  max-width: 280px;
}

.tap-title { color: #fff; font-weight: 700; margin-bottom: 6px; }
.tap-sub { color: #ddd; font-size: var(--font-size-sm); margin-bottom: 12px; }

.tap-btn {
  appearance: none;
  border: none;
  border-radius: var(--radius-card);
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
  background: #4f46e5;
  color: #fff;
}
.tap-btn:hover { filter: brightness(1.05); }

/* === Toast message === */
/* Both legacy `.toast` and new UI kit `.ui-toast` share styles */
.toast, .ui-toast {
  position: fixed;
  left: 50%; /* default center; overridden when anchored */
  bottom: 20px; /* default bottom; cleared when anchored */
  transform: translateX(-50%) translateY(16px);
  background: #2a2a2a;
  color: #f1f1f1;
  border: 1px solid #3a3a3a;
  border-radius: var(--radius-card);
  padding: 10px 14px;
  font-size: var(--font-size-base);
  line-height: 1;
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 9999;
  display: inline-flex;
  align-items: center;
  height:fit-content;
  box-sizing: border-box;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: min(260px, calc(100vw - 24px));
}
.toast.show, .ui-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
