:root {
    --bg-main: #0b0f19;
    --bg-card: #151d2f;
    --bg-card-hover: #1e293b;
    --accent: #38bdf8;
    --accent-glow: rgba(56, 189, 248, 0.25);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --danger: #ef4444;
    --warning: #f59e0b;
    --success: #10b981;
    --border: #334155;
    --header-height: 50px;
    --nav-height: 60px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html, body {
    width: 100%;
    height: 100%;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport for Android/iOS browsers */
    overflow: hidden;
    position: fixed;
    background-color: var(--bg-main);
    color: var(--text-primary);
}

/* Header */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: #0f172a;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    z-index: 1000;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    transition: background 0.3s;
}

.status-dot.connected {
    background: var(--success);
    box-shadow: 0 0 10px var(--success);
}

.status-dot.disconnected {
    background: var(--danger);
    box-shadow: 0 0 8px var(--danger);
}

.app-title {
    font-size: 14px;
    font-weight: 600;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 15px;
}

.icon-btn:active {
    background: var(--bg-card-hover);
    transform: scale(0.95);
}

/* Fixed Main Content Area */
.app-content {
    position: fixed;
    top: var(--header-height);
    bottom: var(--nav-height);
    left: 0;
    right: 0;
    overflow: hidden;
}

.view-panel {
    display: none;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.view-panel.active {
    display: flex;
    flex-direction: column;
}

/* Screen View (Zoom & Pan) */
#viewScreen {
    background: #000;
    overflow: hidden;
    position: relative;
}

.screen-controls-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 42px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
    background: rgba(15, 23, 42, 0.9);
    border-bottom: 1px solid rgba(51, 65, 85, 0.7);
    z-index: 200;
    overflow-x: auto;
    white-space: nowrap;
}

.pill-btn {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 5px 10px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    flex-shrink: 0;
}

.pill-btn.active {
    background: #0284c7;
    border-color: var(--accent);
    color: #fff;
}

.badge {
    margin-left: auto;
    background: #334155;
    padding: 3px 7px;
    border-radius: 10px;
    font-size: 11px;
    font-family: monospace;
}

/* Floating Zoom Bar */
.floating-zoom-bar {
    position: absolute;
    right: 12px;
    top: 50px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 300;
}

.zoom-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid var(--accent);
    color: #fff;
    font-size: 16px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    cursor: pointer;
}

.zoom-btn.reset {
    font-size: 11px;
    border-radius: 12px;
    height: 32px;
}

.zoom-btn:active {
    transform: scale(0.92);
    background: var(--accent);
    color: #000;
}

/* Floating Quick Keys Bar on Screen */
.floating-key-bar {
    position: absolute;
    bottom: 8px;
    left: 8px;
    right: 8px;
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 8px;
    z-index: 400;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.8);
}

.quick-input-row {
    display: flex;
    gap: 6px;
}

.quick-input-row input {
    flex: 1;
    background: #0b0f19;
    border: 1px solid var(--border);
    color: #fff;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 13px;
    outline: none;
}

.quick-shortcuts-row {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding-bottom: 2px;
}

.f-btn {
    background: #1e293b;
    border: 1px solid var(--border);
    color: #f1f5f9;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}

.f-btn:active {
    background: var(--accent);
    color: #000;
}

/* Viewport for Pan & Zoom */
.screen-viewport {
    position: absolute;
    top: 42px;
    bottom: 0;
    left: 0;
    right: 0;
    overflow: hidden;
    touch-action: none; /* Crucial for multi-touch pinch gestures */
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
}

.screen-canvas-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transform-origin: 0 0;
    will-change: transform;
}

.screen-canvas-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
    pointer-events: auto;
}

.screen-placeholder {
    position: absolute;
    color: var(--text-secondary);
    font-size: 13px;
    text-align: center;
    padding: 20px;
    pointer-events: none;
}

/* Trackpad View */
#viewTrackpad {
    padding: 12px;
    gap: 10px;
    height: 100%;
}

.trackpad-surface {
    flex: 1;
    background: linear-gradient(145deg, #131b2e, #0e1526);
    border: 2px dashed var(--border);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.5);
}

.trackpad-hint {
    text-align: center;
    color: var(--text-secondary);
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.trackpad-hint span {
    font-size: 15px;
    font-weight: 600;
}

.trackpad-hint small {
    font-size: 11px;
    opacity: 0.7;
}

.trackpad-buttons {
    display: flex;
    gap: 10px;
    height: 64px;
}

.mouse-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.mouse-btn:active {
    background: var(--accent);
    color: #000;
    transform: scale(0.97);
}

.left-btn { flex: 2; }
.middle-btn { flex: 1; font-size: 12px; }
.right-btn { flex: 2; }

/* Keyboard View */
#viewKeyboard {
    padding: 14px;
    gap: 14px;
}

.quick-text-bar {
    display: flex;
    gap: 8px;
}

.quick-text-bar input {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: #fff;
    padding: 12px;
    border-radius: 10px;
    font-size: 14px;
    outline: none;
}

.primary-btn {
    background: #0284c7;
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.primary-btn:active {
    background: #0369a1;
}

.macro-section h3 {
    font-size: 13px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin: 14px 0 8px;
}

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

.grid-buttons.combos {
    grid-template-columns: repeat(2, 1fr);
}

.grid-buttons.fn-keys {
    grid-template-columns: repeat(3, 1fr);
}

.macro-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 12px 6px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
}

.macro-btn:active {
    background: var(--accent);
    color: #000;
}

/* Terminal View */
#viewTerminal {
    padding: 10px;
    height: 100%;
}

.terminal-container {
    flex: 1;
    background: #030712;
    border: 1px solid var(--border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.terminal-output {
    flex: 1;
    padding: 10px;
    font-family: Consolas, monospace;
    font-size: 12px;
    color: #38bdf8;
    overflow-y: auto;
    white-space: pre-wrap;
    user-select: text;
}

.terminal-input-bar {
    display: flex;
    align-items: center;
    background: #0f172a;
    border-top: 1px solid var(--border);
    padding: 8px 10px;
    gap: 6px;
}

.prompt-symbol {
    color: var(--success);
    font-family: monospace;
    font-weight: bold;
}

.terminal-input-bar input {
    flex: 1;
    background: transparent;
    border: none;
    color: #fff;
    font-family: monospace;
    font-size: 13px;
    outline: none;
}

/* File Explorer */
#viewFiles {
    height: 100%;
}

.files-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: #0f172a;
    border-bottom: 1px solid var(--border);
}

.current-path {
    font-size: 12px;
    color: var(--accent);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: monospace;
    flex: 1;
}

.file-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.file-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    gap: 10px;
    cursor: pointer;
}

.file-icon { font-size: 18px; }

.file-details {
    flex: 1;
    overflow: hidden;
}

.file-name {
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-size {
    font-size: 11px;
    color: var(--text-secondary);
}

.file-action-btn {
    background: #1e293b;
    border: 1px solid var(--border);
    color: var(--accent);
    padding: 5px 8px;
    border-radius: 6px;
    font-size: 11px;
    text-decoration: none;
}

.upload-bar {
    padding: 10px 14px;
    background: #0f172a;
    border-top: 1px solid var(--border);
}

.upload-label {
    display: block;
    background: var(--bg-card);
    border: 1px dashed var(--accent);
    color: var(--accent);
    text-align: center;
    padding: 10px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
}

/* Power & Processes View */
#viewPower {
    padding: 14px;
    gap: 14px;
}

.power-cards {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
}

.card h3 {
    font-size: 14px;
    margin-bottom: 10px;
}

.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

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

.power-action-btn {
    background: #1e293b;
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 14px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
}

.power-action-btn.warn { border-color: var(--warning); color: var(--warning); }
.power-action-btn.danger { border-color: var(--danger); color: var(--danger); }

.process-list {
    max-height: 220px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.process-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    background: #0f172a;
    border-radius: 6px;
    font-size: 12px;
}

.process-name {
    font-family: monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 170px;
}

.kill-btn {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 11px;
}

/* FIXED BOTTOM NAVIGATION BAR */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: #0f172a;
    border-top: 2px solid #1e293b;
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 9999;
    padding-bottom: max(env(safe-area-inset-bottom), 4px);
    box-shadow: 0 -4px 16px rgba(0,0,0,0.7);
}

.nav-tab {
    background: none;
    border: none;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    flex: 1;
}

.nav-tab.active {
    color: var(--accent);
}

.nav-tab.active .nav-icon {
    transform: scale(1.15);
}

.nav-icon {
    font-size: 20px;
    transition: transform 0.15s;
}

.nav-label {
    font-size: 11px;
    font-weight: 600;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.88);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
}

.modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 20px;
    max-width: 320px;
    width: 100%;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.8);
}

.modal-icon { font-size: 36px; margin-bottom: 8px; }
.modal-box h2 { font-size: 18px; margin-bottom: 6px; }
.modal-box p { font-size: 12px; color: var(--text-secondary); margin-bottom: 14px; }
.modal-box input {
    width: 100%;
    padding: 12px;
    background: #0f172a;
    border: 2px solid var(--border);
    border-radius: 10px;
    color: #fff;
    font-size: 22px;
    letter-spacing: 5px;
    text-align: center;
    margin-bottom: 14px;
    outline: none;
}
.modal-box input:focus { border-color: var(--accent); }
.error-msg { color: var(--danger); font-size: 12px; margin-top: 8px; min-height: 16px; }

@keyframes rippleAnim {
    0% { transform: scale(0.5); opacity: 1; }
    100% { transform: scale(2.2); opacity: 0; }
}


/* Voice & Antigravity Assistant Styles */
#viewVoice {
    padding: 12px;
    height: 100%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.voice-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 20px;
}

.voice-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    text-align: center;
}

.voice-lang-bar {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-secondary);
}

.lang-select {
    background: #0f172a;
    border: 1px solid var(--border);
    color: #fff;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 13px;
    outline: none;
}

.mic-sphere-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 10px 0;
}

.big-mic-btn {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    border: none;
    color: #fff;
    font-size: 38px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.4);
    position: relative;
    z-index: 2;
    transition: all 0.2s;
}

.big-mic-btn:active {
    transform: scale(0.95);
}

.big-mic-btn.listening {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    box-shadow: 0 8px 28px rgba(239, 68, 68, 0.6);
}

.big-mic-btn.listening .mic-pulse {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid #ef4444;
    animation: micPulseAnim 1.4s infinite ease-out;
    z-index: 1;
}

@keyframes micPulseAnim {
    0% { transform: scale(1); opacity: 0.9; }
    100% { transform: scale(1.9); opacity: 0; }
}

.mic-status {
    margin-top: 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.mic-status.active {
    color: #ef4444;
    animation: blinkText 1s infinite alternate;
}

@keyframes blinkText {
    from { opacity: 0.7; }
    to { opacity: 1; }
}

.transcript-box {
    width: 100%;
    background: #0f172a;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
}

.transcript-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-secondary);
}

#voiceTranscriptArea {
    width: 100%;
    background: #030712;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
    color: #fff;
    font-size: 14px;
    resize: none;
    outline: none;
    font-family: inherit;
}

.transcript-actions {
    display: flex;
    gap: 8px;
}

.transcript-actions .primary-btn {
    flex: 1;
    padding: 10px;
    font-size: 12px;
    font-weight: 600;
}

.transcript-actions .submit-btn {
    background: linear-gradient(135deg, #10b981, #059669);
}

.voice-options {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
    font-size: 12px;
    color: var(--text-secondary);
    padding: 0 4px;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.toggle-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

.antigravity-hub-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 14px;
}

.card-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 4px 0 10px;
}

.active-badge {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.4);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 11px;
}

.agy-btn {
    background: #1e293b;
    border-color: #3b82f6;
    color: #93c5fd;
}

.commands-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 14px;
}

.cmd-list {
    margin: 8px 0 0 18px;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.cmd-list strong {
    color: var(--text-primary);
}

.mic-btn.active {
    background: #ef4444 !important;
    color: #fff !important;
    animation: micPulseAnim 1.2s infinite;
}
