/* ─── Opsifly Design Tokens ─────────────────────────────────────────────── */
:root {
    --bg-base: #050505;
    --bg-surface: rgba(255,255,255,0.02);
    --bg-surface-hover: rgba(255,255,255,0.05);
    --bg-elevated: rgba(255,255,255,0.04);
    --border-glass: rgba(255,255,255,0.06);
    --border-subtle: rgba(255,255,255,0.04);

    --primary: #7c3aed;
    --primary-hover: #8b5cf6;
    --primary-bg: rgba(124,58,237,0.10);
    --primary-bg-hover: rgba(124,58,237,0.18);
    --primary-border: rgba(124,58,237,0.20);
    --primary-glow: rgba(124,58,237,0.35);
    --primary-active-bg: rgba(124,58,237,0.25);
    --primary-active-border: rgba(124,58,237,0.50);

    --secondary: #3b82f6;
    --accent-green: #34d399;
    --danger: #ff4444;
    --danger-bg: rgba(255,68,68,0.1);
    --danger-border: rgba(255,68,68,0.3);

    --text-primary: #ffffff;
    --text-secondary: #d4d4d4;
    --text-muted: rgba(255,255,255,0.35);
    --text-dim: rgba(255,255,255,0.20);

    --gradient-btn: linear-gradient(135deg, #7c3aed, #3b82f6);

    --radius-container: 16px;
    --radius-button: 12px;
    --radius-pill: 100px;

    --font-ui: 'Outfit', system-ui, -apple-system, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', monospace;

    --blur: blur(24px);
}

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

html {
    height: -webkit-fill-available;
    /* iOS safe-area support */
    --sat: env(safe-area-inset-top, 0px);
    --sab: env(safe-area-inset-bottom, 0px);
    --sal: env(safe-area-inset-left, 0px);
    --sar: env(safe-area-inset-right, 0px);
}

body {
    font-family: var(--font-ui);
    background: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: -webkit-fill-available;
    min-height: var(--vh, 100vh);
    display: flex;
    flex-direction: column;
    margin: 0;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
    /* Prevent iOS tap highlight */
    -webkit-tap-highlight-color: transparent;
    /* Eliminate 300ms tap delay */
    touch-action: manipulation;
}

/* Subtle ambient background glow */
/* clean dark background — no ambient glow */

/* ─── Header ────────────────────────────────────────────────────────────── */
.header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(5,5,5,0.85);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    padding: 12px 20px;
    padding-top: calc(12px + var(--sat));
    padding-left: calc(20px + var(--sal));
    padding-right: calc(20px + var(--sar));
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

h1 {
    font-size: 1.3rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
    white-space: nowrap;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

h1:hover {
    opacity: 0.8;
}

.version {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 300;
}

.controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ─── Buttons ───────────────────────────────────────────────────────────── */
button {
    background: var(--primary-bg);
    color: var(--primary);
    border: 1px solid var(--primary-border);
    padding: 0;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-button);
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

button:hover:not(:disabled) {
    background: var(--primary-bg-hover);
    border-color: var(--primary);
    box-shadow: 0 0 12px var(--primary-glow);
    transform: scale(1.05);
}

button:disabled {
    background: rgba(255,255,255,0.02);
    border-color: var(--border-glass);
    color: var(--text-dim);
    cursor: not-allowed;
    opacity: 0.4;
}

button.danger {
    color: var(--danger);
    border-color: var(--danger-border);
    background: var(--danger-bg);
}

button.danger:hover:not(:disabled) {
    background: rgba(255,68,68,0.2);
    border-color: var(--danger);
    box-shadow: 0 0 12px rgba(255,68,68,0.4);
}

/* Tooltip on hover */
button[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-base);
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    border: 1px solid var(--border-glass);
}

button[data-tooltip]:hover::after {
    opacity: 1;
}

/* ─── Status Indicator ──────────────────────────────────────────────────── */
.status {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ffa500;
    display: inline-block;
    box-shadow: 0 0 8px rgba(255,165,0,0.6);
    transition: all 0.3s ease;
    position: relative;
}

.status.connected {
    background: var(--accent-green);
    box-shadow: 0 0 12px rgba(52,211,153,0.8);
    animation: pulse 2s infinite;
}

.status.error {
    background: #ff0000;
    box-shadow: 0 0 12px rgba(255,0,0,0.8);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Status tooltip */
.status::after {
    content: attr(data-status);
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-base);
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    border: 1px solid var(--border-glass);
}

.status:hover::after {
    opacity: 1;
}

/* ─── Terminal Container ────────────────────────────────────────────────── */
.terminal-container {
    flex: 1;
    padding: 15px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 200px;
}

#terminal {
    flex: 1;
    background: var(--bg-base);
    min-height: 0;
}

/* Hide scrollbars on terminal viewport */
#terminal .xterm-viewport {
    overflow-y: scroll !important;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#terminal .xterm-viewport::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

/* Prevent line-height/letter-spacing from bleeding into xterm measurement */
.xterm, .xterm * {
    line-height: normal !important;
    letter-spacing: normal !important;
    font-kerning: normal !important;
}

/* ─── Info Footer ───────────────────────────────────────────────────────── */
.info {
    background: var(--bg-surface);
    padding: 10px 20px;
    border-top: 1px solid var(--border-glass);
    font-size: 12px;
    color: var(--text-muted);
}

/* ─── Tunnels Section ───────────────────────────────────────────────────── */
.tunnels {
    background: var(--bg-surface);
    padding: 15px 20px;
    border-top: 1px solid var(--border-glass);
}

.tunnels h3 {
    margin-bottom: 10px;
    color: var(--accent-green);
    font-size: 1.1rem;
}

.tunnel-item {
    background: var(--bg-elevated);
    padding: 10px;
    margin-bottom: 8px;
    border-radius: 4px;
    border-left: 3px solid var(--accent-green);
}

.tunnel-item a {
    color: var(--secondary);
    text-decoration: none;
}

.tunnel-item a:hover {
    text-decoration: underline;
}

/* ─── Auth Screen ───────────────────────────────────────────────────────── */
.screen {
    display: none;
    flex: 1;
    overflow: auto;
    min-height: 0;
}

.screen.active {
    display: flex;
}

#auth-screen {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    padding-bottom: calc(20px + var(--sab));
}

.auth-container {
    max-width: 500px;
    width: 100%;
}

.auth-prompt {
    color: var(--primary);
    font-size: 1.2rem;
    margin-bottom: 20px;
    font-weight: 600;
}

.auth-description {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 30px;
    line-height: 1.6;
}

.auth-input-group {
    margin-bottom: 20px;
}

.auth-input-label {
    color: var(--primary);
    font-size: 0.9rem;
    margin-bottom: 8px;
    display: block;
    font-weight: 500;
}

.auth-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 16px; /* min 16px prevents iOS auto-zoom on focus */
    border-radius: var(--radius-button);
    transition: all 0.3s ease;
    letter-spacing: 0.3em;
    text-align: center;
}

.auth-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 8px var(--primary-glow);
}

.auth-input::placeholder {
    letter-spacing: normal;
}

.auth-button {
    width: 100%;
    padding: 14px 28px;
    background: var(--gradient-btn);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-button);
    font-family: var(--font-ui);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.auth-button:hover:not(:disabled) {
    box-shadow: 0 0 20px var(--primary-glow);
    transform: translateY(-1px);
}

.auth-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.auth-error {
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
    color: var(--danger);
    padding: 12px 16px;
    border-radius: var(--radius-button);
    margin-top: 20px;
    font-size: 0.9rem;
}

.auth-info {
    background: rgba(59,130,246,0.1);
    border: 1px solid rgba(59,130,246,0.3);
    color: var(--secondary);
    padding: 12px 16px;
    border-radius: var(--radius-button);
    margin-top: 20px;
    font-size: 0.9rem;
    line-height: 1.6;
}

.auth-info code {
    background: rgba(0,0,0,0.3);
    padding: 2px 6px;
    border-radius: 3px;
    color: var(--primary);
}

/* ─── Launchpad Screen ──────────────────────────────────────────────────── */
#launchpad-screen {
    flex-direction: column;
    padding: 20px;
}

/* ─── Launchpad ─────────────────────────────────────────────────────────── */
.launchpad {
    max-width: 680px;
    width: 100%;
    margin: 0 auto;
    padding: 48px 24px 64px;
}

/* Hero */
.launchpad__hero {
    text-align: center;
    margin-bottom: 40px;
}

.launchpad__title {
    font-size: clamp(1.6rem, 4vw, 2.4rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.15;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #fff 0%, #4b5563 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.launchpad__subtitle {
    color: rgba(255,255,255,0.45);
    font-size: 0.95rem;
    font-weight: 400;
}

/* New-project card variant */
/* Active session indicator (green dot on folder icon) */
.project-card__active {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #22c55e;
    border: 2px solid var(--bg-base);
    box-shadow: 0 0 6px rgba(34,197,94,0.5);
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { box-shadow: 0 0 6px rgba(34,197,94,0.5); }
    50% { box-shadow: 0 0 12px rgba(34,197,94,0.8); }
}

.project-card--active {
    border-color: rgba(34,197,94,0.2);
}

.project-card--active:hover {
    border-color: rgba(34,197,94,0.4);
    box-shadow: 0 0 12px rgba(34,197,94,0.12);
}

/* Running session card */
.project-card--running {
    border-color: rgba(34,197,94,0.25);
    background: rgba(34,197,94,0.04);
    margin-bottom: 24px;
}

.project-card--running:hover {
    border-color: rgba(34,197,94,0.45);
    background: rgba(34,197,94,0.08);
    box-shadow: 0 0 16px rgba(34,197,94,0.15);
}

.project-card__icon--running {
    background: rgba(34,197,94,0.10);
    border: 1px solid rgba(34,197,94,0.25);
}

.project-card__reconnect-hint {
    color: #22c55e;
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    margin-left: auto;
    padding-left: 12px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.project-card--running:hover .project-card__reconnect-hint {
    opacity: 1;
}

/* New project card */
.project-card--new {
    border-style: dashed;
    margin-bottom: 48px;
}

.project-card__icon--new {
    background: rgba(124,58,237,0.08);
    border: 1px dashed var(--primary-border);
}

/* Section */
.launchpad__section {
    margin-bottom: 40px;
}

.launchpad__section--server {
    margin-bottom: 0;
    overflow: hidden;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Section label pill */
.launchpad__label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    border-radius: 100px;
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.06);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.35);
    margin-bottom: 20px;
}

.launchpad__label-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
}

/* Project grid */
.launchpad__grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.launchpad__loading {
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 24px;
    text-align: center;
}

/* Project card */
.project-card {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 16px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25,0.46,0.45,0.94);
    position: relative;
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
}

.project-card:hover {
    background: rgba(255,255,255,0.04);
    border-color: rgba(255,255,255,0.1);
    box-shadow: 0 0 0 1px rgba(124,58,237,0.08), 0 8px 32px -8px rgba(124,58,237,0.15);
    transform: translateY(-1px);
}

.project-card__icon {
    position: relative;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--primary-bg);
    border: 1px solid var(--primary-border);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.project-card:hover .project-card__icon {
    background: var(--primary-bg-hover);
    border-color: var(--primary);
    box-shadow: 0 0 12px var(--primary-glow);
}

.project-card__body {
    flex: 1;
    min-width: 0;
}

.project-card__header {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}

.project-card__name {
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.project-card__badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 100px;
    background: rgba(124,58,237,0.12);
    border: 1px solid rgba(124,58,237,0.25);
    color: var(--primary-hover);
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.project-card__desc {
    color: rgba(255,255,255,0.5);
    font-size: 0.82rem;
    line-height: 1.5;
    margin-bottom: 6px;
}

.project-card__path {
    color: rgba(255,255,255,0.2);
    font-size: 0.72rem;
    font-family: var(--font-mono);
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-all;
}

/* Delete button — only visible on hover */
.project-card__delete {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: transparent;
    color: rgba(255,255,255,0.2);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    opacity: 0;
}

.project-card:hover .project-card__delete {
    opacity: 1;
}

.project-card__delete:hover {
    background: rgba(255,68,68,0.12);
    color: #ff4444;
}

/* Empty state */
.launchpad__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: rgba(255,255,255,0.3);
    font-size: 0.9rem;
    padding: 48px 24px;
    text-align: center;
}

.launchpad__empty-hint {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.15);
}

/* Server button */
.launchpad__server-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: fit-content;
    max-width: 100%;
    padding: 10px 20px;
    background: transparent;
    color: rgba(255,255,255,0.3);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--radius-button);
    font-family: var(--font-ui);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
    overflow: hidden;
}

.launchpad__server-btn svg {
    flex-shrink: 0;
}

.launchpad__server-btn:hover {
    color: rgba(255,255,255,0.6);
    border-color: rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.02);
}

/* ─── Terminal Screen ───────────────────────────────────────────────────── */
#terminal-screen {
    flex-direction: column;
}

/* ─── Mobile Responsive ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .header {
        padding: 10px 15px;
        padding-top: calc(10px + var(--sat));
        padding-left: calc(15px + var(--sal));
        padding-right: calc(15px + var(--sar));
    }

    h1 {
        font-size: 1.1rem;
    }

    .controls button {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }

    .status {
        width: 14px;
        height: 14px;
    }

    .controls {
        gap: 6px;
    }

    .terminal-container {
        padding: 8px;
        min-height: 0;
        flex: 1;
    }

    .info {
        display: none;
    }

    .launchpad {
        padding: 24px 16px 48px;
        padding-bottom: calc(48px + var(--sab));
    }

    .project-card {
        padding: 14px;
        gap: 12px;
    }

    .project-card__icon {
        width: 38px;
        height: 38px;
    }

    /* Show delete button always on touch (no hover) */
    .project-card__delete {
        opacity: 0.5;
    }

    /* Modal safe-area */
    .modal-content {
        max-height: calc(100dvh - var(--sat) - var(--sab) - 40px);
        overflow-y: auto;
    }

    /* Auth inputs: ensure 16px to prevent iOS zoom */
    .modal-input {
        font-size: 16px;
    }

    /* Prevent body scroll when modal is open */
    body.modal-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
    }

    #auth-screen {
        padding-bottom: calc(20px + var(--sab));
    }

    #launchpad-screen {
        padding-bottom: var(--sab);
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1rem;
    }

    .version {
        display: none;
    }

    .controls button {
        width: 40px;
        height: 40px;
    }

    .header {
        padding: 8px 12px;
        padding-top: calc(8px + var(--sat));
    }

    .terminal-container {
        padding: 4px;
    }

    .auth-prompt {
        font-size: 1.1rem;
    }

    .launchpad__title {
        font-size: 1.4rem;
    }

    .project-card__path {
        font-size: 0.65rem;
    }
}

/* ─── Mobile D-Pad ──────────────────────────────────────────────────────── */
.dpad-float-button {
    display: none;
    position: fixed;
    bottom: calc(20px + var(--sab));
    right: calc(20px + var(--sar));
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary-bg);
    border: 2px solid var(--primary-border);
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 9998;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.dpad-float-button:hover,
.dpad-float-button:active {
    background: var(--primary-bg-hover);
    border-color: var(--primary-active-border);
    transform: scale(1.05);
    box-shadow: 0 0 16px var(--primary-glow);
}

.dpad-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    animation: fadeIn 0.2s ease;
}

.dpad-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 40px;
}

@keyframes slideInFromBottomRight {
    from {
        opacity: 0;
        transform: translate(calc(50vw - 50%), calc(50vh - 50%)) scale(0.3);
    }
    to {
        opacity: 1;
        transform: translate(0, 0) scale(1);
    }
}

.dpad-esc {
    position: absolute;
    top: -20px;
    left: -20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--primary-bg);
    border: 2px solid var(--primary-border);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    animation: slideInFromBottomRight 0.3s ease-out;
}

.dpad-esc:active {
    background: var(--primary-active-bg);
    border-color: var(--primary-active-border);
    transform: scale(0.95);
}

.dpad-shift-tab {
    position: absolute;
    bottom: -20px;
    left: -20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--primary-bg);
    border: 2px solid var(--primary-border);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    animation: slideInFromBottomRight 0.3s ease-out;
}

.dpad-shift-tab:active {
    background: var(--primary-active-bg);
    border-color: var(--primary-active-border);
    transform: scale(0.95);
}

.dpad-tab {
    position: absolute;
    bottom: -20px;
    right: -20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--primary-bg);
    border: 2px solid var(--primary-border);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    animation: slideInFromBottomRight 0.3s ease-out;
}

.dpad-tab:active {
    background: var(--primary-active-bg);
    border-color: var(--primary-active-border);
    transform: scale(0.95);
}

.dpad-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    animation: slideInFromBottomRight 0.3s ease-out;
}

.dpad-row {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.dpad-spacer {
    width: 75px;
    height: 75px;
}

.dpad-key {
    width: 75px;
    height: 75px;
    border-radius: var(--radius-button);
    background: var(--primary-bg);
    border: 2px solid var(--primary-border);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.dpad-key:active,
.dpad-key.active {
    background: var(--primary-active-bg);
    border-color: var(--primary-active-border);
    transform: scale(0.92);
    box-shadow: 0 0 20px var(--primary-glow);
}

.dpad-enter {
    border-radius: 50%;
}

/* Mobile only display */
@media (min-width: 769px) {
    .dpad-float-button {
        display: none !important;
    }
}

/* ─── Server Health Card ───────────────────────────────────────────────── */
.server-health {
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 16px;
    padding: 20px;
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
}

.server-health__loading,
.server-health__error {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
    padding: 12px;
}

.server-health__error {
    color: var(--text-dim);
}

.server-health__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.server-health__metric {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.server-health__metric-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.server-health__metric-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.server-health__metric-value {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.server-health__bar {
    height: 6px;
    background: rgba(255,255,255,0.06);
    border-radius: 3px;
    overflow: hidden;
}

.server-health__bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s ease;
}

.server-health__bar-fill--uptime {
    background: var(--primary) !important;
    opacity: 0.4;
}

.server-health__processes {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.server-health__proc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.server-health__proc-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.server-health__proc-cols {
    display: flex;
    gap: 12px;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
}

.server-health__proc-cols span {
    width: 42px;
    text-align: right;
}

.server-health__proc-row {
    display: flex;
    align-items: center;
    padding: 4px 0;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}

.server-health__proc-row:last-child {
    border-bottom: none;
}

.server-health__proc-name {
    flex: 1;
    font-size: 0.8rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.server-health__proc-stat {
    width: 42px;
    text-align: right;
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
    margin-left: 12px;
}

.server-health__proc-stat--mem {
    color: var(--text-dim);
}

@media (max-width: 480px) {
    .server-health__grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .server-health {
        padding: 14px;
    }

    .server-health__proc-name {
        font-size: 0.75rem;
    }

    .server-health__proc-stat {
        font-size: 0.7rem;
        width: 36px;
        margin-left: 8px;
    }

    .server-health__proc-cols span {
        width: 36px;
    }
}

/* ─── Utility Classes ───────────────────────────────────────────────────── */
.hidden {
    display: none !important;
}

/* ─── Modals ────────────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: rgba(5,5,5,0.90);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-container);
    padding: 30px;
    max-width: 500px;
    width: 90%;
    animation: slideIn 0.3s ease;
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    color: var(--text-primary);
    font-size: 1.3rem;
    margin-bottom: 20px;
    font-weight: 700;
}

.modal-body {
    margin-bottom: 25px;
}

.modal-input-group {
    margin-bottom: 20px;
}

.modal-label {
    color: var(--primary);
    font-size: 0.9rem;
    margin-bottom: 8px;
    display: block;
    font-weight: 500;
}

.modal-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: 1rem;
    border-radius: var(--radius-button);
    transition: all 0.3s ease;
}

.modal-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 8px var(--primary-glow);
}

.modal-input::placeholder {
    color: var(--text-dim);
}

.modal-description {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 6px;
}

.modal-message {
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.5;
    margin-bottom: 10px;
}

.modal-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.modal-btn {
    padding: 10px 24px;
    border-radius: var(--radius-button);
    font-family: var(--font-ui);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid;
    width: auto;
    height: auto;
}

.modal-btn-primary {
    background: var(--gradient-btn);
    color: #ffffff;
    border: none;
}

.modal-btn-primary:hover {
    box-shadow: 0 0 16px var(--primary-glow);
    transform: translateY(-1px);
}

.modal-btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border-glass);
}

.modal-btn-secondary:hover {
    background: var(--bg-surface);
    border-color: var(--primary);
}

/* ─── Slash Commands Button ─────────────────────────────────────────────── */
.slash-commands-btn {
    position: fixed;
    bottom: calc(20px + var(--sab));
    left: calc(20px + var(--sal));
    width: 48px;
    height: 48px;
    background: var(--primary-bg);
    border: 2px solid var(--primary-border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9998;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.slash-commands-btn:hover,
.slash-commands-btn:active {
    background: var(--primary-bg-hover);
    border-color: var(--primary-active-border);
    transform: scale(1.05);
    box-shadow: 0 0 16px var(--primary-glow);
}

/* ─── Slash Commands Modal ──────────────────────────────────────────────── */
.modal {
    display: none !important;
}

.modal.active {
    display: flex !important;
}

.modal .modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease;
}

.slash-commands-modal-content {
    background: rgba(5,5,5,0.90);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-container);
    width: 90%;
    max-width: 700px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
    position: relative;
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
}

.slash-commands-modal-content .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-glass);
}

.slash-commands-modal-content .modal-header h2 {
    color: var(--text-primary);
    font-size: 1.3rem;
    margin: 0;
    font-weight: 700;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--primary);
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.modal-close:hover {
    transform: scale(1.1);
    color: var(--primary-hover);
}

.slash-commands-modal-content .modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.common-commands-section {
    margin-bottom: 30px;
}

.common-commands-section h3 {
    color: var(--primary);
    font-size: 1rem;
    margin: 0 0 12px 0;
    font-weight: 500;
    text-transform: lowercase;
}

.common-commands-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.command-button {
    background: var(--primary-bg);
    border: 2px solid var(--primary-border);
    color: var(--text-secondary);
    padding: 12px 10px;
    border-radius: var(--radius-button);
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    transition: all 0.2s ease;
    text-align: center;
    min-height: 45px;
    width: 31%;
    display: flex;
    align-items: center;
    justify-content: center;
    word-break: break-word;
    overflow-wrap: break-word;
}

.command-button:hover,
.command-button:active {
    background: var(--primary-active-bg);
    border-color: var(--primary-active-border);
    color: var(--primary);
    transform: scale(0.95);
    box-shadow: 0 0 20px var(--primary-glow);
}

.all-commands-section {
    border-top: 1px solid var(--border-glass);
    padding-top: 20px;
}

.all-commands-section h3 {
    color: var(--primary);
    font-size: 1rem;
    margin: 0 0 16px 0;
    font-weight: 500;
    text-transform: lowercase;
}

.all-commands-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.command-category h4 {
    color: var(--primary);
    font-size: 0.9rem;
    margin: 0 0 8px 0;
    font-weight: 500;
    opacity: 0.8;
}

.command-item {
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    padding: 12px 16px;
    border-radius: var(--radius-button);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.command-item:hover {
    background: var(--bg-surface-hover);
    border-color: var(--primary);
    transform: translateX(4px);
}

.command-name {
    color: var(--primary);
    font-family: var(--font-mono);
    font-size: 0.95rem;
    font-weight: bold;
}

.command-description {
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.4;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .slash-commands-modal-content {
        width: 95%;
        max-height: calc(100dvh - var(--sat) - var(--sab) - 20px);
    }

    .slash-commands-modal-content .modal-body {
        padding: 16px;
    }

    .common-commands-grid {
        gap: 8px;
    }

    .command-button {
        padding: 12px 8px;
        font-size: 0.75rem;
        min-height: 48px;
        width: 31%;
    }

    .all-commands-section {
        padding-top: 16px;
    }

    .command-item {
        padding: 12px 14px;
        min-height: 48px;
    }
}
