:root {
    /* --- Main UI Variables (Updated to match Default theme) --- */
    --bg: #030308; /* Background color from Default theme */
    --panel: rgba(255, 255, 255, 0.03); /* Panel background from Default theme */
    --glass: rgba(255, 255, 255, 0.04); /* Glass effect from Default theme */
    --accent1: 220 88% 60%; /* Accent color 1 from Default theme */
    --accent2: 280 88% 60%; /* Accent color 2 from Default theme */
    --accent3: 140 75% 50%; /* Accent color 3 from Default theme */
    --text-color: #e6eef8; /* Text color from Default theme */
    --button-text-color: #ffffff; /* Button text color from Default theme */

    /* --- Settings Theme (Simplified) --- */
    --settings-bg: #18181b;
    --settings-surface: #27272a;
    --settings-surface-hover: #3f3f46;
    --settings-text-main: #f4f4f5;
    --settings-text-muted: #a1a1aa;
    --settings-border: #333;
    --status-green: #10b981;
    --status-red: #ef4444;
}

body,
html,
#app {
    font-family: "Inter", system-ui, sans-serif;
    width: 100vw;
    height: 100vh;
    margin: 0;
    background: var(--bg);
    overflow: hidden;
    color: var(--text-color);
}

/* --- LAYOUT & MAIN UI --- */

.flex {
    display: flex;
}

.browser-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.nav {
    padding: 0.6rem;
    gap: 0.5rem;
    display: flex;
    align-items: center;
    background: var(--bg);
}

.nav button {
    color: var(--text-color);
    outline: none;
    border: none;
    border-radius: 8px;
    background: var(--button-bg);
    padding: 0.6rem 1rem;
    cursor: pointer;
    transition: 0.2s ease;
    font-size: 1.1rem;
}

.nav button:hover {
    background-color: var(--button-hover);
}

input.bar {
    font-family: "Inter", sans-serif;
    padding: 0.6rem 1rem;
    border: none;
    outline: none;
    color: var(--text-color);
    border-radius: 8px;
    flex: 1;
    background: var(--button-bg);
    font-size: 1.1rem;
    transition: 0.2s ease;
}

input.bar:focus {
    background-color: var(--button-hover);
}

/* --- TABS --- */

.tabs {
    padding: 0.6rem 0.6rem 0;
    gap: 0.3rem;
    overflow-x: auto;
    white-space: nowrap;
    display: flex;
    background: var(--background-color, var(--bg));
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-repeat: no-repeat;
    background-image:
        radial-gradient(circle at 25% 25%, rgba(255, 255, 255, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 75% 75%, rgba(255, 255, 255, 0.05) 0%, transparent 50%),
        var(--background-color, var(--bg));
}

.tabs::-webkit-scrollbar {
    height: 4px;
}

.tabs::-webkit-scrollbar-track {
    background: transparent;
}

.tabs::-webkit-scrollbar-thumb {
    background: var(--third-bg);
    border-radius: 1px;
}

.tab {
    color: var(--text-color);
    outline: 2px solid transparent;
    border: 2px solid transparent;
    border-radius: 8px 8px 0 0;
    background: var(--button-bg);
    padding: 0.5rem 1rem;
    width: 245px;
    min-width: 245px;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
    font-size: 1rem;
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    position: relative;
}

.tab.active {
    background-color: var(--button-hover);
    outline: 2px solid rgba(255, 255, 255, 0.6);
    border-color: rgba(255, 255, 255, 0.6);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    z-index: 2;
}

.tab:hover:not(.active) {
    background-color: var(--third-bg);
    outline: 1px solid rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
    z-index: 2;
}

.tab-favicon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    border-radius: 4px;
}

.tab-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tab-close {
    background: none;
    border: none;
    color: var(--secondary-text-color);
    cursor: pointer;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: 0.2s ease;
    font-size: 1.2rem;
}

.tab-close:hover {
    background-color: var(--third-bg);
    color: var(--text-color);
}

.new-tab {
    color: var(--text-color);
    border-radius: 8px;
    background: var(--button-bg);
    padding: 0.7rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
    font-size: 1rem;
    border: 2px solid transparent;
}

.new-tab:hover {
    background-color: var(--button-hover);
    outline: 2px solid rgba(255, 255, 255, 0.4);
    transform: translateY(-1px);
}

/* --- IFRAME & LOADING --- */

.iframe-container {
    flex: 1;
    position: relative;
    background: #fff;
}

.iframe-container iframe {
    width: 100%;
    height: 100%;
    border: none;
    position: absolute;
}

.iframe-container iframe.hidden {
    display: none;
}

.loading-bar-container {
    width: 100%;
    height: 2px;
    position: relative;
    z-index: 100;
}

.loading-bar {
    height: 100%;
    background: #ffffff;
    width: 0%;
    transition: width 0.2s ease, opacity 0.2s ease;
}

/* --- SPINNER --- */
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.tab-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    flex-shrink: 0;
}

/* --- SETTINGS MODAL (Fixed & Simplified) --- */

.wisp-settings-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.2s ease;
}

.wisp-settings-modal.hidden {
    opacity: 0;
    pointer-events: none;
    display: none; /* Critical for hiding it properly */
}

.settings-card {
    background: var(--settings-bg);
    width: 420px;
    max-width: 90vw;
    border-radius: 12px;
    border: 1px solid var(--settings-border);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalPop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Header */
.settings-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--settings-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--settings-surface);
}

.settings-header h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--settings-text-main);
    display: flex;
    align-items: center;
    gap: 10px;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--settings-text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    color: var(--text-color);
    background: var(--settings-surface-hover);
}

/* Content */
.settings-content {
    padding: 20px;
    overflow-y: auto;
    max-height: 60vh;
}

.section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--settings-text-muted);
    margin-bottom: 12px;
    margin-top: 4px;
    font-weight: 700;
}

/* --- Server List & Status --- */
.server-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 24px;
}

.wisp-option {
    background: var(--settings-surface);
    border: 1px solid transparent;
    padding: 12px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.wisp-option:hover {
    background: var(--settings-surface-hover);
    border-color: rgba(255, 255, 255, 0.1);
}

.wisp-option.active {
    background: rgba(85, 145, 245, 0.15);
    border-color: var(--primary);
}

.wisp-option-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.wisp-option-name {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--settings-text-main);
    display: flex;
    align-items: center;
}

.wisp-option-url {
    font-family: "Consolas", monospace;
    font-size: 0.75rem;
    color: var(--settings-text-muted);
    word-break: break-all;
}

/* Status Container (Holds Text + Dot) */
.server-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ping-text {
    font-family: "Consolas", monospace;
    font-size: 0.8rem;
    color: var(--settings-text-muted);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--settings-text-muted);
    flex-shrink: 0;
}

.status-indicator.status-success { background: var(--status-green); box-shadow: 0 0 6px rgba(16, 185, 129, 0.4); }
.status-indicator.status-error { background: var(--status-red); }
.status-indicator.status-loading { opacity: 0.5; }
/* Custom Input */
.custom-input-group {
    display: flex;
    gap: 8px;
}

.custom-input-group input {
    flex: 1;
    background: var(--button-bg);
    border: 1px solid var(--settings-border);
    padding: 10px 12px;
    border-radius: 6px;
    color: var(--text-color);
    font-family: "Consolas", monospace;
    font-size: 0.85rem;
    outline: none;
    transition: 0.2s;
}

.custom-input-group input:focus {
    border-color: var(--primary);
    background: var(--settings-surface);
}

.custom-input-group button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: 0.2s;
}

.custom-input-group button:hover {
    opacity: 0.9;
}

/* Footer */
.settings-footer {
    padding: 12px 20px;
    background: rgba(0,0,0,0.1);
    border-top: 1px solid var(--settings-border);
    color: var(--settings-text-muted);
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.delete-wisp-btn {
    background: transparent;
    border: none;
    color: var(--settings-text-muted);
    cursor: pointer;
    padding: 4px;
    margin-left: 8px;
    transition: 0.2s;
}
.delete-wisp-btn:hover {
    color: var(--status-red);
}
/* Sortable Helpers */
.sortable-ghost {
    opacity: 0.5;
}

.sortable-drag {
    transform: rotate(2deg);
    cursor: grabbing;
}
