* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
body {
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #0d0d1a;
    color: #eee;
    overflow: hidden;
}
#deck-canvas {
    width: 100vw;
    height: 100vh;
}

/* Search */
#search-box {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(22, 33, 62, 0.95);
    border-radius: 8px;
    padding: 12px;
    width: 300px;
    z-index: 10;
}
#search-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #334;
    border-radius: 4px;
    background: #1a1a2e;
    color: #eee;
    font-size: 14px;
    outline: none;
}
#search-input:focus {
    border-color: #0f9;
}
#search-input::placeholder {
    color: #667;
}
#autocomplete {
    max-height: 240px;
    overflow-y: auto;
    margin-top: 4px;
}
.ac-item {
    padding: 4px 8px;
    cursor: pointer;
    font-size: 13px;
    border-radius: 4px;
    color: #ccc;
    display: flex;
    align-items: center;
    gap: 8px;
}
.ac-item:hover,
.ac-item.selected {
    background: #2a3a5e;
}
.ac-item:hover .ac-text,
.ac-item.selected .ac-text {
    color: #0f9;
}
.ac-handle {
    color: #0f9;
}
.ac-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ac-check {
    width: 16px;
    height: 16px;
    border: 2px solid #556;
    border-radius: 3px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: transparent;
    transition: all 0.15s;
}
.ac-check:hover {
    border-color: #aaa;
}
.ac-check.checked {
    color: #fff;
}
.sel-order {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(255, 100, 180, 0.3);
    color: rgb(255, 100, 180);
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
    margin-left: 4px;
}
#selections {
    margin-top: 4px;
    max-height: 400px;
    overflow-y: auto;
}
#selections:empty {
    margin-top: 0;
}
.sel-divider {
    height: 1px;
    background: #334;
    margin: 6px 0;
}

/* Auth */
#auth-btn {
    background: rgba(22, 33, 62, 0.9);
    border: none;
    color: #0f9;
    padding: 8px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}
#auth-btn:hover {
    background: rgba(22, 33, 62, 1);
    color: #0da;
}
#auth-btn.authenticated {
    color: #0f9;
}
#auth-modal {
    position: absolute;
    bottom: 44px;
    left: 0;
    background: rgba(22, 33, 62, 0.98);
    border: 1px solid #334;
    border-radius: 8px;
    padding: 16px;
    z-index: 30;
    min-width: 280px;
}
#auth-modal h3 {
    margin: 0 0 12px 0;
    font-size: 14px;
    color: #fff;
}
#auth-modal input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #334;
    border-radius: 4px;
    background: #1a1a2e;
    color: #eee;
    font-size: 13px;
    outline: none;
    margin-bottom: 8px;
}
#auth-modal input:focus {
    border-color: #0f9;
}
#auth-modal input::placeholder {
    color: #667;
}
#auth-login-btn, #auth-logout-btn {
    width: 100%;
    padding: 8px;
    border: none;
    border-radius: 4px;
    background: #0f9;
    color: #000;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 4px;
}
#auth-login-btn:hover {
    background: #0da;
}
#auth-logout-btn {
    background: #f44;
}
#auth-logout-btn:hover {
    background: #d33;
}
#auth-status {
    font-size: 12px;
    color: #aaa;
    margin-top: 8px;
}
.auth-tab {
    flex: 1;
    padding: 6px 12px;
    border: 1px solid #334;
    border-radius: 4px;
    background: transparent;
    color: #aaa;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}
.auth-tab:hover {
    border-color: #556;
    color: #ccc;
}
.auth-tab.active {
    background: #0f9;
    color: #000;
    border-color: #0f9;
    font-weight: 600;
}
#auth-oauth-btn {
    width: 100%;
    padding: 8px;
    border: none;
    border-radius: 4px;
    background: #0f9;
    color: #000;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 4px;
}
#auth-oauth-btn:hover {
    background: #0da;
}

/* Import follows */
#import-follows, #interpolate-section, #filter-section, #groups-section {
    margin-top: 8px;
    border-top: 1px solid #334;
    padding-top: 8px;
}
#midpoint-section {
    margin-top: 12px;
}
#import-toggle, #interpolate-toggle, #filter-toggle, #groups-toggle {
    color: #89f;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
}
#import-toggle:hover, #interpolate-toggle:hover, #filter-toggle:hover, #groups-toggle:hover {
    color: #abf;
}
#import-form, #interpolate-form, #filter-form, #groups-form {
    margin-top: 8px;
}
#import-form .import-row, #interpolate-form .import-row, #filter-form .import-row, #groups-form .import-row {
    display: flex;
    gap: 6px;
}
#import-handle, #interpolate-count, #midpoint-count, #surrounding-count, #list-name, #list-url, #filter-follower-count {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #334;
    border-radius: 4px;
    background: #1a1a2e;
    color: #eee;
    font-size: 13px;
    outline: none;
}
#import-handle:focus, #interpolate-count:focus, #midpoint-count:focus, #surrounding-count:focus, #list-name:focus, #list-url:focus, #filter-follower-count:focus {
    border-color: #0f9;
}
#import-handle::placeholder, #interpolate-count::placeholder, #midpoint-count::placeholder, #surrounding-count::placeholder, #list-name::placeholder, #list-url::placeholder, #filter-follower-count::placeholder {
    color: #667;
}
#import-btn, #import-list-btn, #preview-path-btn, #create-list-btn, #find-midpoint-btn, #find-surrounding-btn, #apply-filter-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    background: #0f9;
    color: #000;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
#import-btn:hover, #import-list-btn:hover, #preview-path-btn:hover, #create-list-btn:hover, #find-midpoint-btn:hover, #find-surrounding-btn:hover, #apply-filter-btn:hover {
    background: #0da;
}
#import-btn:disabled, #import-list-btn:disabled, #preview-path-btn:disabled, #create-list-btn:disabled, #find-midpoint-btn:disabled, #find-surrounding-btn:disabled, #apply-filter-btn:disabled {
    background: #556;
    color: #889;
    cursor: not-allowed;
}
#clear-path-btn, #clear-midpoint-btn, #clear-surrounding-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    background: #f44;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
#clear-path-btn:hover, #clear-midpoint-btn:hover, #clear-surrounding-btn:hover {
    background: #d33;
}
#groups-form button {
    padding: 6px 12px;
    border: 1px solid #557;
    border-radius: 4px;
    background: #1a2540;
    color: #acd;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
#groups-form button:hover {
    background: #243050;
    border-color: #779;
    color: #cef;
}
#import-status, #list-import-status, #interpolate-status, #filter-status {
    font-size: 12px;
    color: #aaa;
    margin-top: 6px;
}
#interpolate-preview, #midpoint-preview, #surrounding-preview {
    font-size: 12px;
    color: #ccc;
    margin-top: 8px;
    padding: 8px;
    background: rgba(0, 255, 153, 0.05);
    border-radius: 4px;
    border: 1px solid rgba(0, 255, 153, 0.2);
}
#interpolate-preview:empty, #midpoint-preview:empty, #surrounding-preview:empty {
    display: none;
}
#midpoint-preview {
    background: rgba(0, 191, 255, 0.05);
    border: 1px solid rgba(0, 191, 255, 0.2);
}
#surrounding-preview {
    background: rgba(138, 43, 226, 0.05);
    border: 1px solid rgba(138, 43, 226, 0.2);
}
#sel-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}
#sel-controls:empty {
    display: none;
}
.sel-mode-btn {
    padding: 3px 8px;
    border: 1px solid #556;
    border-radius: 4px;
    background: transparent;
    color: #aaa;
    font-size: 11px;
    cursor: pointer;
}
.sel-mode-btn:hover {
    border-color: #89f;
    color: #ccc;
}
.sel-mode-btn.active {
    border-color: rgb(255, 100, 180);
    color: rgb(255, 100, 180);
    background: rgba(255, 100, 180, 0.1);
}

/* Status */
#bottom-bar {
    position: absolute;
    bottom: 20px;
    left: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 10;
}
#status {
    background: rgba(22, 33, 62, 0.9);
    padding: 8px 14px;
    border-radius: 4px;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

/* Settings */
#settings-btn {
    background: rgba(22, 33, 62, 0.9);
    border: none;
    color: #aaa;
    width: 36px;
    height: 36px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}
#settings-btn:hover {
    color: #fff;
}
#info-btn {
    background: rgba(22, 33, 62, 0.9);
    color: #aaa;
    text-decoration: none;
    width: 36px;
    height: 36px;
    border-radius: 4px;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
}
#info-btn:hover {
    color: #fff;
}
#settings-modal {
    display: none;
    position: absolute;
    bottom: 44px;
    left: 0;
    background: rgba(22, 33, 62, 0.98);
    border: 1px solid #334;
    border-radius: 8px;
    padding: 16px;
    z-index: 30;
    min-width: 200px;
}
#settings-modal label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    color: #ccc;
}
#settings-modal label:hover {
    color: #fff;
}
#settings-modal input[type="checkbox"] {
    accent-color: #0f9;
}

/* Tooltip */
#tooltip {
    position: absolute;
    background: rgba(22, 33, 62, 0.98);
    padding: 10px 14px;
    border-radius: 8px;
    pointer-events: none;
    display: none;
    font-size: 13px;
    border: 1px solid #0f9;
    max-width: 320px;
    z-index: 20;
}
#tooltip .tt-handle {
    color: #0f9;
    font-weight: bold;
}
#tooltip .tt-name {
    color: #fff;
    font-weight: bold;
    margin-bottom: 2px;
}
#tooltip .tt-bio {
    color: #aaa;
    font-size: 12px;
    margin: 4px 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
#tooltip .tt-stats {
    color: #888;
    font-size: 12px;
}
#tooltip .tt-stats span {
    color: #ddd;
}
#tooltip .tt-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    float: left;
    margin-right: 10px;
    background: #2a2a4e;
}

/* Sidebar */
#sidebar {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(22, 33, 62, 0.95);
    border-radius: 8px;
    padding: 14px;
    width: 300px;
    z-index: 10;
    display: none;
}
#sidebar h3 {
    color: #0f9;
    margin-bottom: 8px;
    word-break: break-all;
    font-size: 15px;
}
#sidebar .profile-link {
    color: #89f;
    text-decoration: none;
    font-size: 13px;
}
#sidebar .profile-link:hover {
    text-decoration: underline;
}
#sidebar .close-btn {
    float: right;
    cursor: pointer;
    color: #888;
    font-size: 24px;
    line-height: 1;
    padding: 0 4px;
}
#sidebar .close-btn:hover {
    color: #fff;
}
#sidebar .sidebar-stats {
    color: #888;
    font-size: 13px;
    margin-top: 6px;
}
#sidebar .sidebar-stats span {
    color: #ddd;
}
#sidebar .sidebar-bio {
    color: #bbb;
    font-size: 13px;
    margin-top: 8px;
}
#sidebar .sidebar-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    margin-right: 12px;
    float: left;
    background: #2a2a4e;
}

::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #334;
    border-radius: 3px;
}

/* Avatar overlay */
#avatar-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
    overflow: hidden;
}
.avatar-pip {
    position: absolute;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #2a2a4e;
    border: 2px solid rgba(255, 255, 255, 0.6);
    transform: translate(-50%, -50%);
    transition: opacity 0.3s;
}

@media (max-width: 640px) {
    #search-box {
        width: calc(100vw - 40px);
        max-width: 300px;
    }
    #search-input {
        font-size: 16px;
    } /* prevent iOS auto-zoom */
    #sidebar {
        width: calc(100vw - 20px);
        left: 10px;
        right: 10px;
        bottom: 10px;
    }
    #status {
        font-size: 12px;
    }
    .ac-check {
        width: 22px;
        height: 22px;
        font-size: 13px;
    } /* bigger touch target */
}

/* Cluster Management */
.cluster-tab {
    transition: all 0.2s ease;
}

.cluster-tab:hover {
    opacity: 0.8;
}

.cluster-tab.active {
    box-shadow: 0 0 8px rgba(0, 255, 255, 0.3);
}
