:root {
    --bg: #2c2f33;
    --card: #23272a;
    --txt: #fff;
    --btn: #5865F2;
    --acc: #3ba55c;
    --border: #202225;
}

/* --- GLOBAL STYLES --- */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg);
    color: var(--txt);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    margin: 0;
    position: relative;
}

/* Main Container Box */
.box {
    background: var(--card);
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
    width: 350px;
    max-width: 90%;
    /* Prevent overflow on mobile */
    z-index: 1;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    transition: width 0.3s ease, opacity 0.3s ease;
}

/* Utility Class */
.hide {
    display: none !important;
}

/* --- BUTTONS --- */
button {
    padding: 12px;
    width: 100%;
    border-radius: 4px;
    border: none;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    margin-top: 10px;
    transition: filter 0.2s;
}

button:hover {
    filter: brightness(1.1);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-login {
    background: var(--btn);
}

.btn-fetch {
    background: var(--acc);
}

/* --- ACCOUNT / MORPHING BUTTON --- */
.accountbtn {
    background: #202225;
    color: #fff;
    position: absolute;
    top: 20px;
    right: 20px;
    border-radius: 8px;
    border: 1px solid #444;
    cursor: pointer;
    cursor: pointer;
    z-index: 2000;
    /* Ensure above dim overlay */
    width: 180px;
    height: 40px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    transition:
        width 0.3s cubic-bezier(0.4, 0, 0.2, 1) 0.15s,
        height 0.3s cubic-bezier(0.4, 0, 0.2, 1) 0.15s,
        background-color 0.3s ease,
        transform 0.1s ease;
}

.accountbtn:hover {
    background: #2f3136;
    transform: translateY(-1px);
}

/* Expanded State (Logout View) */
.accountbtn.expanded {
    width: 300px;
    height: 140px;
    background: var(--card);
    cursor: default;
    border-color: #5865F2;
    transform: none !important;
    transition:
        width 0.3s cubic-bezier(0.4, 0, 0.2, 1) 0s,
        height 0.3s cubic-bezier(0.4, 0, 0.2, 1) 0s;
}

/* Button Contents */
.btn-content-normal {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.2s ease 0.3s;
}

.accountbtn.expanded .btn-content-normal {
    opacity: 0;
    position: absolute;
    pointer-events: none;
    transition: opacity 0.1s ease 0s;
}

.btn-content-logout {
    position: absolute;
    width: 100%;
    text-align: center;
    pointer-events: none;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.15s ease 0s, transform 0.15s ease 0s;
}

.accountbtn.expanded .btn-content-logout {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
    position: relative;
    transition: opacity 0.3s ease 0.2s, transform 0.3s ease 0.2s;
}

.logouttext {
    margin: 0 0 15px 0;
    font-size: 0.95rem;
    color: #dcddde;
}

.logout-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.logout-actions button {
    width: auto;
    padding: 8px 16px;
    margin: 0;
    font-size: 0.9rem;
}

.btn-logout {
    background: #ed4245;
}

.btn-logout:hover {
    background: #c03537;
}

.btn-cancel {
    background: #4f545c;
}

/* Backdrop for logout */
.logOutContainer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.logOutContainer.active {
    opacity: 1;
    pointer-events: auto;
}

/* --- SERVER SWITCHER --- */
.switcher-grid {
    display: grid;
    grid-template-columns: 1fr;
    /* Single column stack or grid? "Open in a grid". Let's do 2 columns if width allows */
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    /* Match dashboard grid logic */
    gap: 10px;
    background: #202225;
    padding: 10px;
    border-radius: 8px;
    /* OVERLAY: Grid sits exactly on top of the container */
    position: absolute;
    top: 0;
    left: 0;
    /* Removed width limit to allow grid to grow naturally, or set max-width? */
    /* Let's set a reasonable max-width so it expands rightwards a bit */
    width: 380px;
    /* Fits approx 3 cols */
    margin: 0;
    /* Remove margin so it overlaps */
    z-index: 1000;

    visibility: hidden;
    opacity: 0;
    /* Scale origin matches the first card position (Top Left) */
    transform: scale(0.9);
    transform-origin: top left;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5);

    /* Ensure click interaction works */
    pointer-events: none;
}

.switcher-container:hover .switcher-grid,
.switcher-container.active .switcher-grid {
    visibility: visible;
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

.server-card.server-card-pop {
    animation: pop-in 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards !important;
    opacity: 0;
    transform: scale(0.8);
    filter: none !important;
    -webkit-filter: none !important;
}

.server-card.server-card-pop .server-avatar {
    filter: none !important;
    -webkit-filter: none !important;
    animation: none !important;
}

@keyframes pop-in {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Mobile Adjustments for Switcher */
@media (max-width: 768px) {
    .switcher-grid {
        top: auto;
        bottom: 0;
        /* Align Bottom */
        left: 0;
        transform-origin: bottom left;
        /* Grow from bottom left corner */
        /* width: 90vw; ? */
    }
}


/* --- DASHBOARD: SERVER GRID --- */
.server-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 15px;
    margin-top: 20px;
    max-height: 400px;
    overflow-y: auto;
    padding: 5px;
    /* Padding for hover effects not to clip */
    border-radius: 14px;
}

/* Custom Scrollbar */
.server-grid::-webkit-scrollbar {
    width: 6px;
}

.server-grid::-webkit-scrollbar-track {
    background: #2f3136;
    border-radius: 4px;
}

.server-grid::-webkit-scrollbar-thumb {
    background: #202225;
    border-radius: 4px;
}

.server-card {
    background: #2f3136;
    border-radius: 8px;
    padding: 15px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    filter: blur(30px);
    -webkit-filter: blur(30px);
    animation: unblurEntry 0.8s ease-out forwards;
}

/* .server-card:hover {
    animation: goToCorner 0.8s ease-out forwards;
} */

.server-avatar {
    filter: blur(30px);
    -webkit-filter: blur(30px);
    animation: unblurEntry 0.8s ease-out 0.3s forwards;
}

@keyframes unblurEntry {
    to {
        filter: blur(0);
        -webkit-filter: blur(0);
    }
}

/* Go to top left of screen */
@keyframes goToCorner {
    0% {
        position: relative;
    }

    to {
        left: 10px;
        top: 10px;
        transform: translate(0px, 0px);
    }
}

.server-card:active {
    animation: none;
}


.server-card:hover {
    background: #36393f;
    transform: translateY(-4px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    border-color: var(--btn);
    animation: unblurEntry 0.8s ease-out forwards, goToCorner 0.8s ease-out forwards;
}

.server-card img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 12px;
    background-color: #202225;
    transition: border-radius 0.2s;
}

.server-card:hover img {
    border-radius: 35%;
    /* Squircle effect like Discord */
}

.server-card span {
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    width: 100%;
    text-align: center;
}


/* --- SETTINGS VIEW --- */
.header-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #36393f;
}

.btn-back {
    background: transparent;
    border: 1px solid #4f545c;
    color: #dcddde;
    width: auto;
    margin: 0;
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn-back:hover {
    background: #4f545c;
    color: #fff;
}

/* Settings Grid Layout */
/* ... Previous CSS (Root, Body, AccountBtn) remains the same ... */

/* --- UPDATED BOX LAYOUT --- */
/* --- UPDATED BOX LAYOUT (2x Size) --- */
.settings-container {
    display: flex;
    /* Massive width increase */
    width: 95vw;
    max-width: 1600px;
    /* Massive height increase */
    height: 85vh;
    min-height: 800px;
    padding: 0;
    overflow: hidden;
    align-items: stretch;
    /* Scale up the font inside this container */
    font-size: 1.2rem;
}

/* --- SIDEBAR STYLES --- */
.sidebar {
    /* Wider sidebar to match the larger scale */
    width: 350px;
    background: #202225;
    display: flex;
    flex-direction: column;
    padding: 30px 20px;
    border-right: 1px solid #2f3136;
    flex-shrink: 0;
    z-index: 2;
}

.sidebar-header h3 {
    margin: 0;
    font-size: 1.5rem;
    /* Larger header */
    margin-left: 15px;
}

.sidebar-header {
    display: flex;
    align-items: center;
    margin-bottom: 30px;
    padding-left: 10px;
}

.sidebar-header h3 {
    margin: 0;
    font-size: 1.1rem;
    margin-left: 10px;
}

.btn-back-icon {
    background: transparent;
    border: 1px solid #4f545c;
    color: #ccc;
    width: 30px;
    padding: 5px;
    margin: 0;
}

.btn-back-icon:hover {
    background: #4f545c;
    color: white;
}

/* Navigation Menu */
.nav-menu {
    position: relative;
    /* Context for the glider */
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.nav-item {
    background: transparent;
    text-align: left;
    padding: 10px 15px;
    color: #b9bbbe;
    font-weight: 500;
    border-radius: 4px;
    position: relative;
    z-index: 2;
    /* Sit on top of glider */
    transition: color 0.2s;
    margin: 0;
}


.nav-item {
    padding: 18px 25px;
    /* Bigger click targets */
    font-size: 1.1rem;
    margin-bottom: 5px;
}

/* Adjust the overshoot glider to match new nav item size */
.glider {
    height: 55px;
    /* Matches new padding roughly */
}

.nav-item:hover {
    color: #dcddde;
}

.nav-item.active {
    color: #fff;
}

/* THE OVERSHOOT GLIDER */
.glider {
    position: absolute;
    height: 40px;
    /* Matches nav-item height roughly */
    width: 100%;
    background: #4f545c;
    /* Active Tab Background Color */
    border-radius: 4px;
    z-index: 1;
    top: 0;
    opacity: 0;
    /* Hidden until JS inits */

    /* The Magic Bounce: cubic-bezier(p1, p2, p3, p4) 
       Values > 1 create the overshoot effect */
    transition: top 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* --- CONTENT VIEWPORT --- */
.content-viewport {
    flex-grow: 1;
    position: relative;
    /* Context for absolute tabs */
    background: var(--card);
    overflow: hidden;
    /* We hide the parent scroll, tabs scroll themselves */
    display: flex;
    /* Ensures children fill space */
}

.tab-pane {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Fill the viewport */
    padding: 30px;
    /* Padding moves inside */
    box-sizing: border-box;
    /* Includes padding in height/width calc */
    overflow-y: auto;
    /* SCROLLING HAPPENS HERE */

    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
    transition: transform 0.4s ease, opacity 0.4s ease;
    z-index: 0;
}

/* Custom Scrollbar for Tabs */
.tab-pane::-webkit-scrollbar {
    width: 8px;
}

.tab-pane::-webkit-scrollbar-track {
    background: #2f3136;
}

.tab-pane::-webkit-scrollbar-thumb {
    background: #202225;
    border-radius: 4px;
}

/* Base Active State */
.tab-pane.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
    z-index: 10;
}

/* --- SLIDING ANIMATIONS --- */
/* These classes are added by JS temporarily */

.tab-pane.animating {
    display: block;
    pointer-events: none;
}

/* Moving DOWN (General -> AI) */
.slide-out-up {
    animation: slideOutUp 0.4s forwards cubic-bezier(0.4, 0, 0.2, 1);
}

.slide-in-up {
    animation: slideInUp 0.4s forwards cubic-bezier(0.4, 0, 0.2, 1);
}

/* Moving UP (AI -> General) */
.slide-out-down {
    animation: slideOutDown 0.4s forwards cubic-bezier(0.4, 0, 0.2, 1);
}

.slide-in-down {
    animation: slideInDown 0.4s forwards cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideOutUp {
    0% {
        opacity: 1;
        transform: translateY(0);
    }

    100% {
        opacity: 0;
        transform: translateY(-50px);
    }
}

@keyframes slideInUp {
    0% {
        opacity: 0;
        transform: translateY(50px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideOutDown {
    0% {
        opacity: 1;
        transform: translateY(0);
    }

    100% {
        opacity: 0;
        transform: translateY(50px);
    }
}

@keyframes slideInDown {
    0% {
        opacity: 0;
        transform: translateY(-50px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Reuse existing grid settings */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.section-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: #b9bbbe;
    text-transform: uppercase;
    margin-bottom: 15px;
    margin-top: 25px;
    border-bottom: 1px solid #3f4147;
    padding-bottom: 5px;
}

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    color: #b9bbbe;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.form-sublabel {
    display: block;
    color: #72767d;
    font-size: 0.8rem;
    margin-bottom: 8px;
    margin-top: -5px;
}

/* Styled Inputs & Selects */
.styled-input,
.styled-select,
.styled-textarea {
    width: 100%;
    background: #202225;
    border: 1px solid #202225;
    color: #dcddde;
    padding: 10px;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.95rem;
    transition: border 0.2s;
    box-sizing: border-box;
    /* Fix padding width issues */
}

.styled-input:focus,
.styled-select:focus,
.styled-textarea:focus {
    outline: none;
    border-color: var(--btn);
}

.styled-textarea {
    resize: vertical;
    min-height: 80px;
}

/* --- TOGGLE SWITCH (iOS Style) --- */
.toggle-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #2f3136;
    padding: 15px;
    /* Reduced padding */
    border-radius: 8px;
    margin-bottom: 10px;
    border: 1px solid #202225;
}

.toggle-label-group {
    display: flex;
    flex-direction: column;
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #72767d;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: #3ba55c;
}

input:focus+.slider {
    box-shadow: 0 0 1px #3ba55c;
}

input:checked+.slider:before {
    transform: translateX(22px);
}

/* --- COMMANDS GRID --- */
.commands-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 10px;
}

.command-card {
    background: #2f3136;
    padding: 10px;
    border-radius: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* --- MOBILE FIXES (Add to bottom of style.css) --- */
@media (max-width: 900px) {

    /* 1. RESET CONTAINER to full screen */
    .settings-container {
        flex-direction: column;
        /* Stack Sidebar on top of Content */
        width: 100vw;
        height: 100vh;
        /* Use full height on mobile */
        max-width: 100%;
        min-height: 0;
        border-radius: 0;
        font-size: 1rem;
        /* Reset font scaling */
    }

    /* 2. SIDEBAR TRANSFORMATION (Top Bar) */
    .sidebar {
        width: 100%;
        height: auto;
        padding: 15px;
        border-right: none;
        border-bottom: 1px solid #2f3136;
        box-sizing: border-box;
        flex-shrink: 0;
        display: block;
        /* Remove flex column constraint */
    }

    .sidebar-header {
        margin-bottom: 15px;
    }

    /* 3. NAVIGATION (Horizontal Scroll) */
    .nav-menu {
        flex-direction: row;
        overflow-x: auto;
        /* Allow horizontal scrolling */
        white-space: nowrap;
        padding-bottom: 10px;
        border-radius: 20px;
        gap: 10px;
        -webkit-overflow-scrolling: touch;
        /* Smooth scroll on iOS */
    }

    /* Turn nav links into "Pills" */
    .nav-item {
        padding: 8px 16px;
        width: fit-content;
        font-size: 0.9rem;
        background: #2f3136;
        border-radius: 20px;
        margin: 0;
        flex-shrink: 0;
        /* Prevent squishing */
        border: 1px solid #202225;
    }

    .nav-item.active {
        background: #5865F2;
        color: white;
        border-color: #5865F2;
    }

    /* Hide the desktop "Glider" animation as it doesn't work horizontally easily */
    .glider {
        display: none !important;
    }

    /* 4. SAVE BUTTON (Move to normal flow) */
    .sidebar>div[style*="margin-top:auto"] {
        margin-top: 10px !important;
        padding: 0;
    }

    /* 5. ACCOUNT BUTTON (Fix overlapping) */
    .accountbtn {
        top: 10px;
        right: 10px;
        transform: scale(0.8);
        /* Shrink it slightly */
        transform-origin: top right;
        width: 40px !important;
        /* Collapse to icon only initially if desired, or keep text */
        height: 40px !important;
        border-radius: 50%;
        padding: 0;
    }

    /* Hide text on mobile account button to save space */
    .accountbtn #lbl-btn-username,
    .accountbtn img {
        margin: 0 !important;
    }

    .accountbtn #lbl-btn-username {
        display: none;
    }

    /* Re-expand on click */
    .accountbtn.expanded {
        width: 250px !important;
        height: 140px !important;
        border-radius: 8px;
        right: 50%;
        transform: translateX(50%) !important;
        /* Center it */
    }

    /* 6. CONTENT AREA */
    .content-viewport {
        width: 100%;
        height: 100%;
        overflow-y: auto;
    }

    .tab-pane {
        padding: 20px 15px;
        /* Reduce padding */
        padding-bottom: 80px;
        /* Space for scrolling */
    }

    /* Adjust grid for mobile */
    .settings-grid,
    .commands-grid {
        grid-template-columns: 1fr;
        /* Single column */
    }

    .toggle-wrapper {
        flex-direction: row;
        /* Keep toggles side-by-side */
        align-items: center;
    }
}

/* Flying Card Animation Class */
/* Flying Card Animation Class (Keyframe based) */
.flying-card {
    /* Set defaults if variables are missing */
    --start-top: 0px;
    --start-left: 0px;
    --end-top: 20px;
    /* Default to top */

    transform-origin: top left !important;
    /* Fix: Match settings.js static card origin */
    position: fixed !important;
    z-index: 6000 !important;
    /* Above everything */
    animation: flyToCorner 0.7s forwards !important;
    pointer-events: none;
    /* Reset transition as we are using animation now */
    transition: none !important;
    filter: none !important;
    -webkit-filter: none !important;
}

@keyframes flyToCorner {
    0% {
        top: var(--start-top);
        left: var(--start-left);
        transform: scale(1);
    }

    90% {
        top: var(--end-top);
        /* "ease-in-out" simulated by curve here if needed, but standard easing applies to keyframe */
    }

    100% {
        top: var(--end-top);
        left: 20px;
        transform: scale(0.6);
        /* Size becomes less */
    }
}

.page-transition-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000;
    z-index: 2500 !important;
    /* Below card, above most things */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.6s ease;
}

.page-transition-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* --- HELP TOOLTIP ICON --- */
.help-icon-wrapper {
    display: inline-flex;
    position: relative;
    vertical-align: middle;
    margin-left: 6px;
}

.help-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #4f545c;
    color: #dcddde;
    font-size: 10px;
    font-weight: bold;
    cursor: help;
    transition: background 0.2s, transform 0.2s;
}

.help-icon:hover {
    background: #5865F2;
    transform: scale(1.1);
}

.help-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #18191c;
    color: #dcddde;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: normal;
    min-width: 300px;
    max-width: 400px;
    white-space: pre-wrap;
    text-align: left;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    z-index: 1000;
    pointer-events: none;
}

.help-tooltip::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #18191c;
}

.help-icon-wrapper:hover .help-tooltip {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.help-tooltip a {
    color: #5865F2;
    text-decoration: underline;
    cursor: pointer;
}

.help-tooltip a:hover {
    color: #7289da;
}

/* --- DICT TYPE STYLES --- */
.dict-container {
    margin-bottom: 20px;
}

.dict-rows {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}

.dict-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.dict-row .dict-key {
    flex: 0 0 35%;
    min-width: 0;
}

.dict-row .dict-value {
    flex: 1;
    min-width: 0;
    min-height: 38px;
    max-height: 150px;
    resize: vertical;
}

.dict-remove-btn {
    width: 32px;
    height: 32px;
    min-width: 32px;
    padding: 0;
    margin: 0;
    background: #ed4245;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.1s;
}

.dict-remove-btn:hover {
    background: #c03537;
    transform: scale(1.05);
}

.dict-add-btn {
    background: #3ba55c;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    width: auto;
    margin: 0;
}

.dict-add-btn:hover {
    background: #2d8049;
}

/* Mobile adjustments for dict */
@media (max-width: 768px) {
    .dict-row {
        flex-wrap: wrap;
    }

    .dict-remove-btn {
        order: 3;
        width: 100%;
        margin-top: 4px;
    }

    .dict-row .dict-key,
    .dict-row .dict-value {
        flex: 1 1 calc(50% - 4px);
    }
}

/* --- EMOJI PICKER --- */
.dict-value-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    flex: 1;
}

.dict-value-wrapper .dict-value {
    flex: 1;
}

.emoji-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    flex-shrink: 0;
    background: #4f545c;
    border: none;
    border-radius: 4px;
    color: #b9bbbe;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    transition: background 0.2s, color 0.2s;
}

.emoji-btn:hover {
    background: var(--btn);
    color: white;
}

/* General Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 9999;
    justify-content: center;
    align-items: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: #2f3136;
    border-radius: 8px;
    padding: 25px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    margin: 20px;
}

.modal-content h3 {
    margin: 0 0 20px 0;
    font-size: 1.3rem;
    color: #fff;
}

.modal-content .close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 24px;
    color: #b9bbbe;
    cursor: pointer;
    background: none;
    border: none;
    width: auto;
    padding: 0;
    margin: 0;
    line-height: 1;
}

.modal-content .close-btn:hover {
    color: white;
}

/* Emoji Modal Overlay */
#emoji-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    justify-content: center;
    align-items: center;
}

#emoji-modal.show {
    display: flex;
}

.emoji-modal-content {
    background: #2f3136;
    border-radius: 8px;
    padding: 20px;
    width: 400px;
    max-width: 90vw;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.emoji-modal-content h3 {
    margin: 0 0 15px 0;
    font-size: 1.2rem;
}

.emoji-modal-content .close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 24px;
    color: #b9bbbe;
    cursor: pointer;
    background: none;
    border: none;
}

.emoji-modal-content .close-btn:hover {
    color: white;
}

.emoji-grid-container {
    flex: 1;
    overflow-y: auto;
    max-height: 50vh;
}

.emoji-category-title {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: #72767d;
    margin: 15px 0 10px 0;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.emoji-category-title:first-child {
    margin-top: 0;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 6px;
}

.emoji-item {
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.4rem;
    transition: background 0.1s, transform 0.1s;
}

.emoji-item:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(1.1);
}

.emoji-item img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

@media (max-width: 768px) {
    .emoji-grid {
        grid-template-columns: repeat(6, 1fr);
    }

    .emoji-modal-content {
        width: 95vw;
        max-height: 80vh;
    }
}

/* --- CHATBOT CARDS --- */
.chatbot-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
    margin-bottom: 10px;
}

.chatbot-card {
    background: #2f3136;
    border-radius: 10px;
    padding: 15px;
    border: 1px solid #202225;
    transition: border-color 0.2s, transform 0.2s;
}

.chatbot-card:hover {
    border-color: #5865F2;
    transform: translateY(-2px);
}

.chatbot-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.chatbot-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    background: #202225;
    flex-shrink: 0;
}

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

.chatbot-name {
    font-weight: 600;
    color: #fff;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chatbot-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.chatbot-edit-btn,
.chatbot-delete-btn {
    background: transparent;
    border: 1px solid #4f545c;
    width: 32px;
    height: 32px;
    padding: 0;
    margin: 0;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: background 0.2s, border-color 0.2s;
}

.chatbot-edit-btn:hover {
    background: #4f545c;
    border-color: #5865F2;
}

.chatbot-delete-btn:hover {
    background: #ed4245;
    border-color: #ed4245;
}

.chatbot-prompt {
    font-size: 0.85rem;
    color: #b9bbbe;
    line-height: 1.4;
    background: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 6px;
    max-height: 60px;
    overflow: hidden;
}