@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --bg-primary: #0f0d0b;
    --bg-secondary: #1a1614;
    --bg-tertiary: #241f1c;
    --bg-card: rgba(26, 22, 20, 0.8);
    --bg-card-hover: rgba(36, 31, 28, 0.9);
    --bg-input: rgba(20, 17, 15, 0.9);
    --border: rgba(140, 118, 102, 0.15);
    --border-hover: rgba(140, 118, 102, 0.3);
    --accent: #8C7666;
    --accent-hover: #7A6558;
    --accent-glow: rgba(140, 118, 102, 0.3);
    --accent-subtle: rgba(140, 118, 102, 0.1);
    --text-primary: #f1ede9;
    --text-secondary: #a89e94;
    --text-muted: #736a62;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --accent-light: #a08270;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: inherit;
}

img {
    max-width: 100%;
}

.bg-effects {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.bg-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.4;
    animation: orbFloat 20s ease-in-out infinite;
}

.bg-orb-1 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(140, 118, 102, 0.3), transparent);
    top: -200px;
    left: -100px;
}

.bg-orb-2 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(160, 130, 108, 0.25), transparent);
    bottom: -150px;
    right: -100px;
    animation-delay: -7s;
}

.bg-orb-3 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(140, 118, 102, 0.2), transparent);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -14s;
}

@keyframes orbFloat {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    25% {
        transform: translate(30px, -40px) scale(1.05);
    }

    50% {
        transform: translate(-20px, 20px) scale(0.95);
    }

    75% {
        transform: translate(10px, 30px) scale(1.02);
    }
}

.landing {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    text-align: center;
    padding: 40px 20px;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    animation: fadeInUp 0.8s ease;
}

.container-wide {
    max-width: 1100px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes cardSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.bot-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 3px solid var(--accent);
    box-shadow: 0 0 40px var(--accent-glow);
    margin-bottom: 24px;
    animation: avatarPulse 3s ease-in-out infinite;
}

.bot-avatar-placeholder {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #a08270);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    margin: 0 auto 24px;
    box-shadow: 0 0 40px var(--accent-glow);
}

@keyframes avatarPulse {

    0%,
    100% {
        box-shadow: 0 0 40px var(--accent-glow);
    }

    50% {
        box-shadow: 0 0 60px rgba(140, 118, 102, 0.5);
    }
}

.bot-name {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #fff, var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 12px;
}

.bot-description {
    color: var(--text-secondary);
    font-size: 1.05rem;
    line-height: 1.7;
    margin-bottom: 32px;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

/* Features Section */
.features-section {
    margin-bottom: 40px;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
    gap: 16px;
    margin-bottom: 32px;
    text-align: start;
}

.feature-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    backdrop-filter: blur(12px);
    transition: var(--transition);
}

.feature-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.feature-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: var(--accent);
    background: rgba(140, 118, 102, 0.14);
    border: 1px solid var(--border);
    border-radius: 14px;
    transition: var(--transition);
}

.feature-card:hover .feature-icon {
    background: rgba(140, 118, 102, 0.24);
    border-color: var(--border-hover);
}

.stat-number {
    font-variant-numeric: tabular-nums;
}

.feature-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.feature-desc {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.buttons-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-bottom: 56px;
}

.buttons-wrapper .btn {
    padding: 16px 36px;
    font-size: 1.05rem;
    border-radius: var(--radius-lg);
    letter-spacing: 0.3px;
}

.landing-buttons {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
    flex-wrap: wrap;
}

.stats-box {
    display: flex;
    justify-content: center;
    gap: 48px;
    margin-bottom: 36px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-number {
    font-size: 2rem;
    font-weight: 800;
    color: var(--accent);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 4px;
}

/* Server Showcase Section */
.showcase-section {
    margin-top: 40px;
    margin-bottom: 40px;
    width: 100vw;
    max-width: 100vw;
    margin-inline: calc(50% - 50vw);
    position: relative;
    overflow: hidden;
}

.showcase-subtitle {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}

.showcase-title {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 28px;
}

.showcase-wrapper {
    overflow: hidden;
    mask-image: linear-gradient(to right, transparent, black 8%, black 92%, transparent);
    -webkit-mask-image: linear-gradient(to right, transparent, black 8%, black 92%, transparent);
    padding: 8px 0;
}

.showcase-track {
    display: flex;
    gap: 20px;
    width: max-content;
    animation: marqueeScroll 30s linear infinite;
}

.showcase-track:hover {
    animation-play-state: paused;
}

.showcase-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 20px;
    backdrop-filter: blur(12px);
    transition: var(--transition);
    flex-shrink: 0;
    min-width: 200px;
    cursor: default;
}

.showcase-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.showcase-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
}

.showcase-icon-placeholder {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #a08270);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.showcase-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-align: start;
}

.showcase-name {
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--text-primary);
    white-space: nowrap;
}

.showcase-members {
    font-size: 0.78rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.showcase-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
    flex-shrink: 0;
}

@keyframes marqueeScroll {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(-50%);
    }
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 32px;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    margin: 6px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #a08270);
    color: #fff;
    box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(140, 118, 102, 0.5);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
    color: var(--text-primary);
    transform: translateY(-2px);
}

.btn-icon {
    font-size: 1.1rem;
}

.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    margin-bottom: 10px;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--border);
}

.nav-username {
    font-weight: 600;
    color: var(--text-primary);
}

.nav-logout {
    padding: 8px 20px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    transition: var(--transition);
    font-size: 0.9rem;
}

.nav-logout:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--danger);
}

.page-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 8px;
}

.page-header-icon {
    font-size: 2rem;
    color: var(--accent);
}

.page-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
}

.page-subtitle {
    color: var(--text-muted);
    margin-bottom: 28px;
    font-size: 0.95rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 28px;
}

.stats-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    backdrop-filter: blur(12px);
    transition: var(--transition);
}

.stats-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.stats-card-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.stats-card-icon.brown {
    background: rgba(140, 118, 102, 0.15);
    color: var(--accent);
}

.stats-card-icon.orange {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.stats-card-icon.red {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.stats-card-icon.green {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.stats-card-number {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stats-card-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.search-box {
    position: relative;
    margin-bottom: 24px;
}

.search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.1rem;
    opacity: 0.5;
}

.search-box input {
    width: 100%;
    padding: 14px 16px 14px 48px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    transition: var(--transition);
    backdrop-filter: blur(12px);
    outline: none;
}

.search-box input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

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

.section-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-title .badge {
    background: var(--accent-subtle);
    color: var(--accent);
    font-size: 0.75rem;
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 600;
}

.server-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
    gap: 16px;
    margin-bottom: 40px;
}

.server-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    backdrop-filter: blur(12px);
    transition: var(--transition);
    animation: cardSlideIn 0.5s ease both;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.server-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.server-card-header {
    display: flex;
    align-items: center;
    gap: 14px;
}

.server-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.server-icon-placeholder {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--accent), #a08270);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

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

.server-name {
    font-weight: 600;
    font-size: 1.05rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.server-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-dot.active {
    background: var(--success);
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
}

.status-dot.inactive {
    background: var(--text-muted);
}

.status-text.active {
    color: var(--success);
}

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

.btn-configure {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    background: linear-gradient(135deg, var(--accent), #a08270);
    color: #fff;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    transition: var(--transition);
}

.btn-configure:hover {
    box-shadow: 0 4px 20px var(--accent-glow);
    transform: translateY(-1px);
}

.btn-invite {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    transition: var(--transition);
}

.btn-invite:hover {
    background: var(--accent-subtle);
    border-color: var(--accent);
    color: var(--accent);
}

.no-servers {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.no-servers-icon {
    font-size: 3rem;
    margin-bottom: 12px;
    color: var(--accent);
    opacity: 0.8;
}

.error-page {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    text-align: center;
    padding: 40px 20px;
}

.error-icon {
    font-size: 5rem;
    margin-bottom: 24px;
    opacity: 0.8;
}

.error-title {
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 12px;
    background: linear-gradient(135deg, #fff, var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.error-description {
    color: var(--text-muted);
    font-size: 1.05rem;
    margin-bottom: 32px;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.6;
}


/* ═══════════════════════════════════════════════════════════════
   Responsive layer
   Phones, tablets, laptops, desktops, ultra-wide and 4K screens,
   touch and mouse, portrait and landscape, notched devices.
   ═══════════════════════════════════════════════════════════════ */

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    color-scheme: dark;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-x: clip;
    -webkit-tap-highlight-color: transparent;
}

:focus-visible {
    outline: 2px solid var(--accent-light);
    outline-offset: 2px;
}

/* Layout shells */
.landing {
    min-height: 100vh;
    min-height: 100dvh;
    padding: max(40px, calc(var(--safe-top) + 24px)) max(20px, var(--safe-right)) max(40px, calc(var(--safe-bottom) + 24px)) max(20px, var(--safe-left));
}

.error-page {
    min-height: 100vh;
    min-height: 100dvh;
    padding: max(40px, calc(var(--safe-top) + 24px)) max(20px, var(--safe-right)) max(40px, calc(var(--safe-bottom) + 24px)) max(20px, var(--safe-left));
}

.container {
    width: 100%;
}

.page-shell {
    padding: calc(10px + var(--safe-top)) max(16px, var(--safe-right)) calc(40px + var(--safe-bottom)) max(16px, var(--safe-left));
}

.section-title-spaced {
    margin-top: 16px;
}

.server-members {
    color: var(--text-muted);
    margin-inline-start: 6px;
}

/* Fluid type */
.bot-name {
    font-size: clamp(1.9rem, 1.3rem + 3vw, 2.75rem);
    overflow-wrap: anywhere;
}

.bot-description {
    font-size: clamp(0.98rem, 0.9rem + 0.4vw, 1.1rem);
}

.stat-number {
    font-size: clamp(1.6rem, 1.2rem + 2vw, 2.25rem);
}

.showcase-title {
    font-size: clamp(1.35rem, 1.1rem + 1.5vw, 1.8rem);
    padding-inline: 16px;
}

.showcase-subtitle {
    padding-inline: 16px;
}

.page-title {
    font-size: clamp(1.4rem, 1.15rem + 1.4vw, 1.8rem);
    overflow-wrap: anywhere;
}

.error-title {
    font-size: clamp(1.7rem, 1.3rem + 2.5vw, 2.2rem);
}

.error-icon {
    font-size: clamp(3.5rem, 2.8rem + 4vw, 5rem);
}

/* Components */
.stats-box {
    flex-wrap: wrap;
    gap: 20px clamp(24px, 6vw, 48px);
}

.buttons-wrapper {
    flex-wrap: wrap;
}

.btn {
    min-height: 48px;
    justify-content: center;
}

.top-nav {
    gap: 12px;
}

.nav-user {
    min-width: 0;
}

.nav-username {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-logout {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    min-height: 40px;
}

.page-subtitle {
    color: var(--text-secondary);
}

.server-status {
    flex-wrap: wrap;
    row-gap: 2px;
}

.btn-configure,
.btn-invite {
    min-height: 44px;
}

.stats-card>div:last-child {
    min-width: 0;
}

.stats-card-number,
.stats-card-label {
    overflow-wrap: anywhere;
}

/* ── Large screens ── */
@media (min-width: 1200px) {
    .container {
        max-width: 720px;
    }

    .container-wide {
        max-width: 1200px;
    }
}

@media (min-width: 1600px) {
    .container-wide {
        max-width: 1320px;
    }
}

@media (min-width: 2200px) {
    html {
        font-size: 112.5%;
    }

    .container {
        max-width: 820px;
    }

    .container-wide {
        max-width: 1560px;
    }
}

/* ── Tablets ── */
@media (max-width: 1000px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* ── Phones and small tablets ── */
@media (max-width: 768px) {
    .landing-buttons {
        flex-direction: column;
        align-items: stretch;
        max-width: 360px;
        margin-inline: auto;
        gap: 12px;
    }

    .landing-buttons .btn,
    .buttons-wrapper .btn {
        margin: 0;
        width: 100%;
    }

    .buttons-wrapper {
        flex-direction: column;
        align-items: stretch;
        max-width: 360px;
        margin-inline: auto;
        margin-bottom: 40px;
    }

    .buttons-wrapper .btn {
        padding: 14px 24px;
        font-size: 1rem;
    }

    .features-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .server-list {
        grid-template-columns: minmax(0, 1fr);
    }

    .stats-card {
        padding: 16px;
        gap: 12px;
    }

    .server-card {
        padding: 16px;
    }

    .showcase-section {
        margin-top: 28px;
        margin-bottom: 28px;
    }

    .showcase-card {
        min-width: 180px;
        padding: 12px 16px;
    }

    .showcase-track {
        gap: 14px;
    }

    /* 16px fields stop iOS from zooming on focus */
    .search-box input {
        font-size: 16px;
        min-height: 48px;
    }

    /* lighter background effects for mobile GPUs */
    .bg-orb {
        filter: blur(80px);
        opacity: 0.35;
    }

    .bg-orb-1 {
        width: 380px;
        height: 380px;
    }

    .bg-orb-2 {
        width: 320px;
        height: 320px;
    }

    .bg-orb-3 {
        width: 260px;
        height: 260px;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .feature-card {
        padding: 16px;
    }

    .page-header {
        gap: 12px;
    }

    .page-header-icon {
        font-size: 1.6rem;
    }

    .page-subtitle {
        margin-bottom: 20px;
    }

    .nav-logout {
        padding: 8px 16px;
    }
}

@media (max-width: 360px) {

    .bot-avatar,
    .bot-avatar-placeholder {
        width: 96px;
        height: 96px;
    }

    .bot-avatar-placeholder {
        font-size: 38px;
    }

    .landing,
    .error-page {
        padding-left: max(14px, var(--safe-left));
        padding-right: max(14px, var(--safe-right));
    }
}

/* ── Landscape phones: short screens ── */
@media (max-height: 520px) and (orientation: landscape) {

    .landing,
    .error-page {
        align-items: flex-start;
        padding-top: max(20px, var(--safe-top));
        padding-bottom: max(20px, var(--safe-bottom));
    }

    .bot-avatar,
    .bot-avatar-placeholder {
        width: 80px;
        height: 80px;
        margin-bottom: 14px;
    }

    .bot-avatar-placeholder {
        font-size: 32px;
    }

    .bot-description {
        margin-bottom: 20px;
    }

    .error-icon {
        font-size: 3rem;
        margin-bottom: 12px;
    }

    .error-description {
        margin-bottom: 20px;
    }
}

/* ── Touch: no sticky hover lifts, press feedback instead ── */
@media (hover: none) {

    .feature-card:hover,
    .server-card:hover,
    .stats-card:hover,
    .showcase-card:hover,
    .btn-primary:hover,
    .btn-secondary:hover,
    .btn-configure:hover {
        transform: none;
        box-shadow: none;
    }

    .btn:active,
    .btn-configure:active,
    .btn-invite:active,
    .nav-logout:active {
        transform: scale(0.97);
    }

    .showcase-track:hover {
        animation-play-state: running;
    }
}

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .showcase-wrapper {
        overflow-x: auto;
        -webkit-mask-image: none;
        mask-image: none;
    }
}

.server-card,
.feature-card,
.stat-card,
.module-card,
.stats-card {
    min-width: 0;
}


/* ═══════════════════════════════════════════════════════════════
   Languages: switcher, Arabic typography, right-to-left layout
   ═══════════════════════════════════════════════════════════════ */

.lang-switch {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 999px;
    backdrop-filter: blur(12px);
    flex-shrink: 0;
}

.lang-btn {
    min-width: 44px;
    min-height: 34px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: var(--transition);
}

.lang-btn[lang="ar"] {
    font-family: 'Tajawal', 'Inter', sans-serif;
    font-size: 0.9rem;
}

.lang-btn:hover {
    color: var(--text-primary);
    background: var(--accent-subtle);
}

.lang-btn.active {
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: #fff;
    box-shadow: 0 2px 12px var(--accent-glow);
}

@media (pointer: coarse) {
    .lang-btn {
        min-height: 40px;
    }
}

/* Arabic typography */
html[lang="ar"] {
    font-size: 106.25%;
}

html[lang="ar"] body,
html[lang="ar"] button,
html[lang="ar"] input,
html[lang="ar"] select,
html[lang="ar"] textarea {
    font-family: 'Tajawal', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Tahoma, sans-serif;
}

/* Letter-spacing breaks the joining of Arabic letters */
html[lang="ar"] * {
    letter-spacing: normal !important;
}

html[lang="ar"] body {
    line-height: 1.65;
}

html[lang="ar"] .bot-name,
html[lang="ar"] .error-title,
html[lang="ar"] .showcase-title {
    line-height: 1.5;
    padding-block: 0.08em;
}

@media (min-width: 2200px) {
    html[lang="ar"] {
        font-size: 119%;
    }
}

/* Mixed-direction names (server names, channels...) follow their own first letter */
.server-name,
.sidebar-guild-name,
.mobile-guild-name,
.showcase-name,
.nav-username,
.item-name,
.manager-role-item-name,
.manager-dropdown-name {
    unicode-bidi: plaintext;
}

.item-name code {
    unicode-bidi: isolate;
}

/* Arrows that point "back" must flip in RTL */
[dir="rtl"] .fa-arrow-left,
[dir="rtl"] .fa-chevron-left,
[dir="rtl"] .fa-sign-out-alt {
    transform: scaleX(-1);
}


.lang-corner {
    position: absolute;
    top: max(16px, calc(var(--safe-top) + 8px));
    inset-inline-end: max(16px, var(--safe-right));
    z-index: 5;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

/* leave room for the corner switcher */
.landing,
.error-page {
    padding-top: max(72px, calc(var(--safe-top) + 64px));
}

@media (max-height: 520px) and (orientation: landscape) {

    .landing,
    .error-page {
        padding-top: max(64px, calc(var(--safe-top) + 56px));
    }
}

/* Right-to-left */
[dir="rtl"] .search-icon {
    left: auto;
    right: 16px;
}

[dir="rtl"] .search-box input {
    padding: 14px 48px 14px 16px;
}

/* the marquee always scrolls left-to-right internally, cards keep the page direction */
.showcase-wrapper {
    direction: ltr;
}

[dir="rtl"] .showcase-card {
    direction: rtl;
}

@media (max-width: 480px) {
    .nav-actions {
        gap: 8px;
    }

    .nav-actions .lang-btn {
        min-width: 38px;
        padding: 0 10px;
    }
}


/* Older Safari (<14.1) ignores inset-inline-end: give the corner switcher a physical fallback */
.lang-corner {
    right: max(16px, var(--safe-right));
}

[dir="rtl"] .lang-corner {
    right: auto;
    left: max(16px, var(--safe-left));
}

.lang-switch {
    white-space: nowrap;
}

/* Narrow phones: the avatar is enough, the name would be squeezed to "U..." next to the switcher */
@media (max-width: 400px) {
    .nav-username {
        display: none;
    }
}


/* Avatar decoration (Discord) around the logged-in user's avatar */
.avatar-deco-wrap {
    position: relative;
    display: inline-flex;
    flex-shrink: 0;
    line-height: 0;
}
.avatar-deco {
    position: absolute;
    top: -10%;
    left: -10%;
    width: 120%;
    height: 120%;
    max-width: none;
    pointer-events: none;
}
