/* BakBot Mini App UI */
:root {
    --app-bg: #0a0e1a;
    --app-bg-2: #0f1525;
    --surface: rgba(255, 255, 255, 0.08);
    --surface-2: rgba(255, 255, 255, 0.12);
    --stroke: rgba(255, 255, 255, 0.15);
    --stroke-2: rgba(255, 255, 255, 0.22);
    --text: rgba(255, 255, 255, 0.95);
    --muted: rgba(255, 255, 255, 0.7);
    --faint: rgba(255, 255, 255, 0.5);

    --accent: #007aff;
    --accent-hover: #0051d5;
    --accent-2: #00c6ff;
    --success: #34c759;
    --warning: #ffcc00;
    --danger: #ff3b30;

    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.4);
    --radius: 16px;
    --radius-sm: 12px;
    --ring: 0 0 0 3px rgba(0, 122, 255, 0.3);

    --nav-height: 76px;
    --container: 980px;

    /* DANGER ZONE (top reserved area)
       Keep UI content below this area; Telegram overlays differ by device/OS.
       Adjust per OS via html[data-os="..."] below. */
    --danger-top: 0px;

    --modal-bg: rgba(15, 20, 35, 0.98);
    --modal-field-bg: rgba(255, 255, 255, 0.06);
}

@media (prefers-color-scheme: light) {
    :root {
        --app-bg: #f5f5f7;
        --app-bg-2: #ffffff;
        --surface: #ffffff;
        --surface-2: #f5f5f7;
        --stroke: rgba(0, 0, 0, 0.12);
        --stroke-2: rgba(0, 0, 0, 0.18);
        --text: #1d1d1f;
        --muted: #6e6e73;
        --faint: #86868b;
        --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
        --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.12);
        --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.16);
        --ring: 0 0 0 3px rgba(0, 122, 255, 0.2);
        --modal-bg: #ffffff;
        --modal-field-bg: #f5f5f7;
    }
}

/* DANGER ZONE - OS-specific safe area offsets */
html[data-os="ios"] { --danger-top: 56px; }
html[data-os="android"] { --danger-top: 44px; }
html[data-os="windows"] { --danger-top: 18px; }
html[data-os="macos"] { --danger-top: 14px; }
html[data-os="linux"] { --danger-top: 14px; }
html[data-os="other"] { --danger-top: 18px; }

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    overflow-x: hidden;
}

body {
    margin: 0;
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: linear-gradient(180deg, var(--app-bg), var(--app-bg-2));
    padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
}

@media (prefers-reduced-motion: reduce) {
    * {
        scroll-behavior: auto !important;
        transition: none !important;
        animation: none !important;
    }
}

/* Section transitions */
.section {
    margin-bottom: 24px;
}

/* Cards */
.server-card, .backup-card, .stat-card {
    border: 1px solid var(--stroke);
    background: var(--surface);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
}

.server-card:hover, .backup-card:hover, .stat-card:hover {
    border-color: var(--stroke-2);
    background: var(--surface-2);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.server-card:active, .backup-card:active, .stat-card:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

.file-list {
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
}

.icon-btn {
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.icon-btn:hover {
    background: var(--surface-2);
    border-color: var(--stroke-2);
    transform: scale(1.05);
}

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

/* Navigation */
.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom, 0px));
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    border-top: 1px solid var(--stroke);
    background: rgba(10, 14, 26, 0.9);
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    z-index: 60;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.2);
}

@media (prefers-color-scheme: light) {
    .bottom-nav {
        background: rgba(255, 255, 255, 0.9);
    }
}

.nav-item {
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    display: grid;
    place-items: center;
    padding: 10px 8px;
    gap: 4px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item.active {
    background: var(--surface);
    border-color: var(--stroke);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

.nav-item:focus-visible {
    outline: none;
    box-shadow: var(--ring);
}

.nav-icon {
    font-size: 20px;
}

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

/* Header */
.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    padding: calc(12px + env(safe-area-inset-top, 0px) + var(--danger-top)) 16px 12px;
    background: rgba(10, 14, 26, 0.85);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--stroke);
}

.app-header::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: calc(env(safe-area-inset-top, 0px) + var(--danger-top));
    pointer-events: none;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.3), transparent);
}

.header-content {
    max-width: var(--container);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    position: relative;
    z-index: 1;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.brand-mark {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: white;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
    flex-shrink: 0;
}

/* Empty State Titles */
.empty-title {
    font-size: 18px;
    letter-spacing: -0.01em;
    margin-top: 8px;
}

/* Loading Spinner */
.spinner {
    width: 48px;
    height: 48px;
    border-radius: 999px;
    border: 3px solid rgba(0, 122, 255, 0.15);
    border-top-color: var(--accent);
    animation: spin 0.8s linear infinite;
    box-shadow: 0 0 20px rgba(0, 122, 255, 0.2);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.ico {
    width: 18px;
    height: 18px;
    display: inline-block;
    fill: currentColor;
    color: currentColor;
    vertical-align: middle;
}

.ico-16 { width: 16px; height: 16px; }
.ico-18 { width: 18px; height: 18px; }
.ico-20 { width: 20px; height: 20px; }
.ico-24 { width: 24px; height: 24px; }

.brand-text {
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.brand-title {
    font-weight: 750;
    letter-spacing: -0.02em;
    font-size: 16px;
}

.brand-subtitle {
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-actions {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 14px;
    border: 1px solid var(--stroke);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    display: grid;
    place-items: center;
    font-size: 16px;
}

.icon-btn:active {
    transform: translateY(1px);
}

.icon-btn:focus-visible {
    outline: none;
    box-shadow: var(--shadow-sm), var(--ring);
}

/* Layout */
.main-container {
    max-width: var(--container);
    margin: 0 auto;
    padding: 12px 16px 24px;
}

.section {
    margin-bottom: 20px;
}

.section.hidden {
    display: none;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 8px 2px 12px;
}

.section-header h2 {
    margin: 0;
    font-size: 16px;
    letter-spacing: -0.01em;
}

/* Buttons */
.btn-primary, .btn-secondary {
    border-radius: var(--radius-sm);
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    user-select: none;
    line-height: 1;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.btn-primary {
    color: white;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    box-shadow: var(--shadow-sm), 0 0 0 0 rgba(0, 122, 255, 0.4);
}

.btn-primary:hover:not(:disabled) {
    box-shadow: var(--shadow-md), 0 0 0 4px rgba(0, 122, 255, 0.2);
    transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    color: var(--text);
    background: var(--surface);
    border-color: var(--stroke);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--surface-2);
    border-color: var(--stroke-2);
    box-shadow: var(--shadow-md);
}

.btn-secondary:active:not(:disabled) {
    transform: scale(0.98);
}

.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary:focus-visible,
.btn-secondary:focus-visible {
    outline: none;
    box-shadow: var(--shadow-sm), var(--ring);
}

.btn-large {
    width: 100%;
    padding: 16px 20px;
    font-size: 15px;
}

/* Modals */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    z-index: 100;
}

.modal.active {
    display: flex;
}

.modal-content {
    width: 100%;
    max-width: 560px;
    max-height: calc(100vh - 48px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    border-radius: var(--radius);
    border: 1px solid var(--stroke-2);
    background: var(--modal-bg);
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    box-shadow: var(--shadow-lg);
    overflow: auto;
}

.modal-content.modal-sheet {
    max-width: 560px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px 16px;
    border-bottom: 1px solid var(--stroke);
}

.modal-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.modal-close {
    border: 1px solid var(--stroke);
    background: var(--surface);
    color: var(--text);
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: var(--surface-2);
    border-color: var(--stroke-2);
}

.modal-body {
    padding: 20px;
}

.modal-body-scrollable {
    max-height: calc(70vh - 120px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-body-scrollable::-webkit-scrollbar {
    width: 6px;
}

.modal-body-scrollable::-webkit-scrollbar-track {
    background: transparent;
}

.modal-body-scrollable::-webkit-scrollbar-thumb {
    background: var(--stroke);
    border-radius: 3px;
}

.modal-body-scrollable::-webkit-scrollbar-thumb:hover {
    background: var(--stroke-2);
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--stroke);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

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

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 8px;
}

.input-field {
    width: 100%;
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    border: 1px solid var(--stroke);
    background: var(--modal-field-bg);
    color: var(--text);
    outline: none;
    font-size: 15px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
}

.input-field:focus {
    background: var(--surface);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.input-field::placeholder {
    color: var(--faint);
}

textarea.input-field {
    resize: vertical;
    min-height: 80px;
    font-family: ui-monospace, "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, "Courier New", monospace;
    font-size: 13px;
    line-height: 1.6;
}

/* Cards / Lists */
.server-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px;
}

.server-card {
    border-radius: var(--radius);
    padding: 16px;
    cursor: pointer;
    min-width: 0;
}

.server-card:focus-visible {
    outline: none;
    box-shadow: var(--shadow-sm), var(--ring);
}

.server-card.active {
    border-color: var(--accent);
    background: linear-gradient(135deg, rgba(0, 122, 255, 0.15), rgba(0, 198, 255, 0.1));
    box-shadow: var(--shadow-md), 0 0 0 1px rgba(0, 122, 255, 0.2);
}

.server-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.server-name {
    font-weight: 700;
    letter-spacing: -0.01em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.server-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--success);
}

.dot.offline {
    background: rgba(255, 255, 255, 0.25);
}

.server-path {
    color: var(--muted);
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 10px;
}

.server-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: var(--faint);
    font-size: 12px;
}

/* Browser */
.browser-header-sticky {
    position: sticky;
    top: calc(env(safe-area-inset-top, 0px) + var(--danger-top) + 60px);
    z-index: 40;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: linear-gradient(180deg, rgba(10, 14, 26, 0.95) 0%, rgba(10, 14, 26, 0.85) 50%, transparent 100%);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
}

.sticky-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.sticky-back-btn,
.sticky-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: var(--shadow-md);
    background: var(--surface);
    border: 1px solid var(--stroke);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.sticky-back-btn:hover:not(:disabled),
.sticky-action-btn:hover:not(:disabled) {
    background: var(--surface-2);
    border-color: var(--stroke-2);
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

.sticky-back-btn:active:not(:disabled),
.sticky-action-btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: var(--shadow-md);
}

.sticky-back-btn:disabled,
.sticky-action-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.sticky-action-btn {
    min-width: 44px;
    justify-content: center;
}

.sticky-action-btn span:not(:empty) {
    min-width: 20px;
    text-align: center;
    font-weight: 700;
}

.browser-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 160px;
    flex-wrap: wrap;
}

.crumb-btn {
    background: var(--surface);
    border: 1px solid var(--stroke);
    color: var(--muted);
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
    max-width: 100%;
}

.crumb-btn.active {
    color: var(--text);
    border-color: var(--stroke-2);
}

.crumb-btn:focus-visible {
    outline: none;
    box-shadow: var(--shadow-sm), var(--ring);
}

.toolbar-actions {
    display: flex;
    gap: 10px;
}

.selection-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.selection-pill {
    background: var(--surface);
    border: 1px solid var(--stroke);
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 12px;
    color: var(--muted);
}

.hint {
    font-size: 12px;
    color: var(--faint);
    text-align: right;
}

.file-list {
    border: 1px solid var(--stroke);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.file-row {
    display: grid;
    grid-template-columns: 32px 36px 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--stroke);
    cursor: pointer;
    min-height: 64px;
    transition: background 0.15s ease;
}

.file-row:focus-visible {
    outline: none;
    box-shadow: inset 0 0 0 2px rgba(124, 92, 255, 0.35);
}

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

.file-row:hover {
    background: var(--surface-2);
}

.file-row:active {
    background: var(--surface);
}

.file-row.selected {
    background: rgba(124, 92, 255, 0.12);
}

.file-checkbox {
    width: 24px;
    height: 24px;
    border-radius: 8px;
    border: 2px solid var(--stroke-2);
    background: var(--surface);
    display: grid;
    place-items: center;
    color: white;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.file-row.selected .file-checkbox {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border-color: transparent;
}

.file-icon {
    font-size: 22px;
    opacity: 0.9;
    color: var(--muted);
    flex-shrink: 0;
}

.file-name {
    font-weight: 600;
    font-size: 15px;
    letter-spacing: -0.01em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
    margin-bottom: 2px;
}

.file-meta {
    display: flex;
    gap: 10px;
    color: var(--faint);
    font-size: 12px;
    margin-top: 2px;
}

.file-text {
    min-width: 0;
}

.file-trailing {
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
}


/* Backups */
.backup-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.backup-card {
    border-radius: var(--radius);
    border: 1px solid var(--stroke);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    padding: 18px;
    transition: all 0.2s ease;
}

.backup-card:hover {
    border-color: var(--stroke-2);
    box-shadow: var(--shadow-md);
}

.backup-top {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.backup-name {
    font-weight: 750;
    letter-spacing: -0.01em;
    font-size: 14px;
}

.backup-sub {
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
}

.backup-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.backup-actions .btn-secondary {
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: auto;
    white-space: nowrap;
}

.backup-actions .btn-secondary svg {
    width: 16px;
    height: 16px;
}

.backup-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    color: var(--faint);
    font-size: 12px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 9px;
    border-radius: 999px;
    border: 1px solid var(--stroke);
    background: rgba(0, 0, 0, 0.10);
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.stat-card {
    border-radius: var(--radius);
    border: 1px solid var(--stroke);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    border: 1px solid var(--stroke);
    background: rgba(0, 0, 0, 0.10);
    font-size: 18px;
}

.stat-label {
    font-size: 12px;
    color: var(--muted);
}

.stat-value {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.02em;
}


/* Empty / Loading */
.loading {
    padding: 32px 16px;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
}

.empty-state {
    padding: 40px 20px;
    text-align: center;
    color: var(--muted);
}

.empty-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    display: grid;
    place-items: center;
    border-radius: var(--radius);
    border: 1px solid var(--stroke);
    background: var(--surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    font-size: 28px;
    color: var(--muted);
}

.empty-title {
    font-weight: 700;
    font-size: 18px;
    color: var(--text);
    margin-bottom: 8px;
    letter-spacing: -0.01em;
}

.empty-subtitle {
    font-size: 14px;
    color: var(--muted);
    line-height: 1.5;
}


.search-input {
    font-size: 15px;
}

.search-results {
    max-height: 420px;
    overflow: auto;
    border-radius: var(--radius);
    border: 1px solid var(--stroke);
    background: rgba(0, 0, 0, 0.14);
}

.help-text {
    font-size: 12px;
    color: var(--faint);
    margin-top: 6px;
}

.help-text code {
    background: rgba(0, 122, 255, 0.12);
    border: 1px solid rgba(0, 122, 255, 0.2);
    border-radius: 6px;
    padding: 2px 6px;
    color: var(--text);
    font-size: 11px;
    font-family: ui-monospace, "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, "Courier New", monospace;
}

.preset-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.preset-btn {
    padding: 8px 10px;
    font-size: 12px;
    border-radius: 12px;
}

/* Toggle */
.toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.toggle input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.toggle-ui {
    width: 44px;
    height: 26px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.18);
    border: 1px solid var(--stroke);
    position: relative;
    flex-shrink: 0;
}

.toggle-ui::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 3px;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    transition: transform 0.18s ease;
}

.toggle input:checked + .toggle-ui {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border-color: transparent;
}

.toggle input:checked + .toggle-ui::after {
    transform: translate(18px, -50%);
}

.toggle-text {
    font-size: 13px;
    color: var(--text);
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 120;
}

.loading-overlay p {
    color: var(--text);
    font-size: 15px;
    font-weight: 500;
    margin: 0;
}

.loading-overlay.hidden {
    display: none;
}


/* Toast */
.toast {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(var(--nav-height) + 16px + env(safe-area-inset-bottom, 0px));
    z-index: 130;
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    border: 1px solid var(--stroke);
    background: rgba(10, 14, 26, 0.9);
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    color: var(--text);
    box-shadow: var(--shadow-lg);
    max-width: var(--container);
    margin: 0 auto;
    font-size: 14px;
    font-weight: 500;
}

@media (prefers-color-scheme: light) {
    .toast {
        background: rgba(255, 255, 255, 0.95);
    }
}

.bottom-actions {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
    padding: 12px 16px 16px;
    background: linear-gradient(180deg, transparent, rgba(10, 14, 26, 0.95) 30%);
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    z-index: 50;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.3);
}

body.has-selection .bottom-actions {
    display: block;
}

.bottom-actions .btn-large {
    max-width: 100%;
    margin: 0;
}

@media (prefers-color-scheme: light) {
    .bottom-actions {
        background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.9) 20%);
    }
}

.toast.hidden {
    display: none;
}

/* Selection Modal */
.selection-list {
    max-height: 50vh;
    overflow-y: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--stroke);
    background: var(--surface);
    padding: 8px;
    margin-bottom: 16px;
    -webkit-overflow-scrolling: touch;
}

.selection-item {
    display: grid;
    grid-template-columns: 40px 36px 1fr;
    gap: 12px;
    align-items: center;
    padding: 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--stroke);
    background: var(--surface-2);
    margin-bottom: 8px;
    transition: all 0.2s ease;
}

.selection-item:last-child {
    margin-bottom: 0;
}

.selection-item:hover {
    background: var(--surface);
    border-color: var(--stroke-2);
}

.selection-item-checkbox {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 2px solid var(--danger);
    background: var(--surface);
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--danger);
}

.selection-item-checkbox:hover {
    background: var(--danger);
    color: white;
    transform: scale(1.1);
}

.selection-item-icon {
    font-size: 24px;
    opacity: 0.9;
    color: var(--muted);
    flex-shrink: 0;
}

.selection-item-content {
    min-width: 0;
}

.selection-item-name {
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.selection-item-meta {
    display: flex;
    gap: 12px;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 4px;
}

.selection-item-path {
    font-size: 11px;
    color: var(--faint);
    font-family: ui-monospace, "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, "Courier New", monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Sort Modal */
.sort-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sort-option {
    width: 100%;
    padding: 16px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--stroke);
    background: var(--surface);
    color: var(--text);
    font-size: 15px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sort-option:hover {
    background: var(--surface-2);
    border-color: var(--stroke-2);
}

.sort-option.active {
    background: linear-gradient(135deg, rgba(0, 122, 255, 0.15), rgba(0, 198, 255, 0.1));
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 600;
}

.sort-option.active::after {
    content: '✓';
    color: var(--accent);
    font-weight: 700;
}

/* Server type toggle */
.server-type-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 18px;
    padding: 4px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--stroke);
    background: rgba(0, 0, 0, 0.12);
}

.type-btn {
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.type-btn.active {
    background: var(--surface);
    border-color: var(--stroke);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

.type-btn:hover:not(.active) {
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
}

/* Small screens */
@media (max-width: 560px) {
    .server-list {
        grid-template-columns: 1fr;
    }
    .modal {
        padding: 0;
        align-items: flex-end;
    }
    .modal-content.modal-sheet {
        max-width: 100%;
        border-radius: 22px 22px 0 0;
        max-height: calc(100vh - 18px - env(safe-area-inset-top, 0px));
    }
}
