@font-face {
    font-family: "Sarasa Term SC";
    src: local("Sarasa Term SC"), local("Sarasa Mono SC"), local("Noto Sans Mono CJK SC");
    font-weight: normal;
    font-style: normal;
    font-display: block;
}

:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --border: #30363d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent: #58a6ff;
    --accent-hover: #79c0ff;
    --danger: #f85149;
    --success: #3fb950;
    --warning: #d29922;
    --font-mono: "Sarasa Term SC", "Sarasa Mono SC", "Noto Sans Mono CJK SC", "JetBrains Mono", "Fira Code", "Consolas", monospace;
    --font-sans: "Sarasa Term SC", system-ui, sans-serif;
}

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

body {
    font-family: var(--font-mono);
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    line-height: 1.5;
}

.hidden { display: none !important; }

.file-input-hidden {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
}

/* Connect Page */
.connect-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: radial-gradient(ellipse at center, #161b22 0%, #0d1117 70%);
    min-height: 100vh;
    overflow-y: auto;
}

.connect-container {
    text-align: center;
    max-width: 420px;
    width: 100%;
    padding: 3rem 2rem;
}

.connect-container h1 {
    font-family: var(--font-mono);
    font-size: 2.2rem;
    font-weight: 600;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #58a6ff 0%, #79c0ff 50%, #a5d6ff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-secondary);
    margin-bottom: 2.5rem;
    font-size: 0.9rem;
}

.connect-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.connect-form label {
    text-align: left;
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.connect-form input[type="text"],
.connect-form input[type="password"] {
    padding: 0.8rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.connect-form input[type="text"]:focus,
.connect-form input[type="password"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

.button-row {
    display: flex;
    gap: 0.5rem;
}

.btn {
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 500;
    transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
    background: #238636;
    color: #fff;
    flex: 1;
}

.btn-primary:hover { background: #2ea043; box-shadow: 0 1px 3px rgba(0,0,0,0.3); }

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    flex: 1;
}

.btn-secondary:hover { background: #30363d; }

.btn-small {
    padding: 0.35rem 0.7rem;
    font-size: 0.75rem;
    border-radius: 6px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-small:hover { background: #30363d; color: var(--text-primary); }

.error-message {
    color: var(--danger);
    font-size: 0.85rem;
    padding: 0.5rem 0.75rem;
    background: rgba(248, 81, 73, 0.1);
    border: 1px solid rgba(248, 81, 73, 0.3);
    border-radius: 6px;
}

/* Session Page */
.session-page {
    display: flex;
    flex-direction: column;
}

#toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.35rem 0.75rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    font-size: 0.8rem;
    flex-shrink: 0;
    height: 36px;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.toolbar-right {
    display: flex;
    gap: 0.35rem;
}

.badge {
    background: rgba(88, 166, 255, 0.15);
    color: var(--accent);
    padding: 0.1rem 0.5rem;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 500;
}

/* Tab Bar */
#tab-bar {
    display: flex;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    height: 34px;
    overflow: hidden;
}

#tab-list {
    display: flex;
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
}

#tab-list::-webkit-scrollbar { display: none; }

.tab-item {
    display: flex;
    align-items: center;
    padding: 0 14px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    cursor: pointer;
    white-space: nowrap;
    min-width: 70px;
    transition: background 0.15s, color 0.15s;
    user-select: none;
}

.tab-item.active {
    color: var(--text-primary);
    background: var(--bg-primary);
    border-bottom: 2px solid var(--accent);
}

.tab-item:hover:not(.active) {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.tab-close {
    margin-left: 8px;
    opacity: 0.3;
    font-size: 0.75rem;
    cursor: pointer;
    transition: opacity 0.15s, color 0.15s;
    padding: 2px 4px;
    border-radius: 3px;
}

.tab-close:hover {
    opacity: 1;
    color: var(--danger);
    background: rgba(248, 81, 73, 0.1);
}

.tab-new-btn {
    padding: 0 14px;
    font-size: 1.1rem;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-left: 1px solid var(--border);
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
    font-family: var(--font-mono);
}

.tab-new-btn:hover {
    color: var(--accent);
    background: var(--bg-secondary);
}

.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

#terminal-container {
    flex: 1;
    overflow: hidden;
}

/* File Drawer */
.file-drawer {
    width: 280px;
    min-width: 180px;
    border-left: 1px solid var(--border);
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.file-resizer {
    width: 4px;
    cursor: col-resize;
    background: transparent;
    flex-shrink: 0;
    transition: background 0.15s;
}

.file-resizer:hover {
    background: var(--accent);
}

.file-drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.8rem;
    font-weight: 500;
}

.file-drawer-toolbar {
    display: flex;
    gap: 0.35rem;
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid var(--border);
    align-items: center;
}


.file-tree {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    padding: 0.35rem 0.55rem;
    font-size: 0.72rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
}
.breadcrumb::-webkit-scrollbar { display: none; }
.breadcrumb-item {
    cursor: pointer;
    padding: 0.15rem 0.3rem;
    border-radius: 3px;
    transition: background 0.1s, color 0.1s;
}
.breadcrumb-item:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.breadcrumb-item.current { color: var(--text-primary); font-weight: 500; cursor: default; }
.breadcrumb-item::after { content: '/'; margin-left: 0.3rem; color: var(--text-muted); }
.breadcrumb-item:last-child::after { content: ''; }
.breadcrumb-item:first-child::after { content: '/'; }


/* File Table */
.paths-table, .uploaders-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.72rem;
    table-layout: fixed;
}

.paths-table thead, .uploaders-table thead {
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 1;
}

.paths-table th, .uploaders-table th {
    text-align: left;
    padding: 0.28rem 0.55rem;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.68rem;
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.paths-table th:nth-child(1) { width: 42%; }
.paths-table th:nth-child(2) { width: 12%; }
.paths-table th:nth-child(3) { width: 16%; }
.paths-table th:nth-child(4) { width: 14%; }
.paths-table th:nth-child(5) { width: 16%; }

.paths-table td, .uploaders-table td {
    padding: 0.2rem 0.55rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-bottom: 1px solid rgba(48, 54, 61, 0.5);
}

.uploaders-table progress {
    width: 100%;
    height: 4px;
    border-radius: 2px;
    accent-color: var(--accent);
}

.file-row {
    cursor: pointer;
    transition: background 0.1s;
    user-select: none;
}

.file-row:hover {
    background: var(--bg-tertiary);
}

.file-row.selected {
    background: rgba(88, 166, 255, 0.12);
    border-left: 3px solid var(--accent);
}

.file-row.selected td:first-child {
    padding-left: calc(0.55rem - 3px);
}

.file-row.selected:hover {
    background: rgba(88, 166, 255, 0.18);
}

.file-name {
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
}
.file-name svg { margin-right: 0.5rem; opacity: 0.6; vertical-align: middle; }
.file-name span { vertical-align: middle; }
.file-name.directory { color: var(--accent); }
.file-name.directory svg { opacity: 1; }

.file-size, .file-perms, .file-owner {
    color: var(--text-secondary);
    font-size: 0.68rem;
}

.file-actions {
    text-align: right;
}

/* Icon Buttons */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: background 0.1s, color 0.1s, border-color 0.1s;
}
.btn-icon:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border);
}
.btn-icon.download { opacity: 0; }
.file-row:hover .btn-icon.download { opacity: 1; }
.btn-icon.delete:hover { background: rgba(248, 81, 73, 0.12); color: var(--danger); }

.file-actions .btn-icon {
    width: 24px;
    height: 24px;
}

.file-error {
    color: var(--danger);
    padding: 2rem 1rem;
    text-align: center;
    font-size: 0.8rem;
}

.file-drawer-toolbar {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.upload-progress {
    border-bottom: 1px solid var(--border);
    padding: 0.4rem 0.55rem;
    font-size: 0.7rem;
}
.upload-progress .uploaders-table { width: 100%; }
.upload-progress .uploaders-table td { padding: 0.15rem 0.3rem; }
.upload-progress progress { width: 60px; height: 4px; accent-color: var(--accent); margin-right: 0.3rem; vertical-align: middle; }
.upload-progress span { color: var(--text-muted); vertical-align: middle; }

/* Toast */
.toast {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    padding: 0.65rem 1rem;
    border-radius: 8px;
    font-size: 0.8rem;
    z-index: 100;
    transition: opacity 0.25s, transform 0.25s;
    animation: toast-in 0.25s ease-out;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.toast.error {
    background: rgba(248, 81, 73, 0.15);
    color: var(--danger);
    border: 1px solid rgba(248, 81, 73, 0.3);
    backdrop-filter: blur(8px);
}

.toast.success {
    background: rgba(63, 185, 80, 0.15);
    color: var(--success);
    border: 1px solid rgba(63, 185, 80, 0.3);
    backdrop-filter: blur(8px);
}

.toast.info {
    background: rgba(88, 166, 255, 0.15);
    color: var(--accent);
    border: 1px solid rgba(88, 166, 255, 0.3);
    backdrop-filter: blur(8px);
}

/* Disconnect Overlay */
.disconnect-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    animation: fade-in 0.2s ease-out;
    backdrop-filter: blur(4px);
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.disconnect-message {
    background: var(--bg-secondary);
    padding: 2rem 2.5rem;
    border-radius: 12px;
    text-align: center;
    border: 1px solid var(--border);
    box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}

.disconnect-message h2 {
    color: var(--danger);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.disconnect-message p {
    margin-bottom: 1.2rem;
    color: var(--text-secondary);
}

/* Context Menu */
.context-menu {
    position: fixed;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.25rem 0;
    z-index: 300;
    min-width: 150px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    animation: fade-in 0.12s ease-out;
}

.context-menu-item {
    padding: 0.45rem 0.85rem;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.1s;
}

.context-menu-item:hover { background: rgba(88, 166, 255, 0.12); }

/* Guide Section (agent usage) */
.guide-section {
    max-width: 680px;
    width: 100%;
    padding: 2.5rem 2rem;
    text-align: left;
    border-top: 1px solid var(--border);
    margin-top: 1rem;
}
.guide-section h2 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 1.2rem;
    text-align: center;
}
.guide-section h3 {
    font-size: 0.9rem;
    color: var(--accent);
    margin-top: 1.2rem;
    margin-bottom: 0.5rem;
}
.guide-section p, .guide-section li {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.7;
}
.guide-section code {
    background: var(--bg-tertiary);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.78rem;
    color: var(--accent);
}
.guide-section pre {
    background: var(--bg-tertiary);
    padding: 0.8rem 1rem;
    border-radius: 6px;
    font-size: 0.78rem;
    color: #7ee787;
    overflow-x: auto;
    line-height: 1.6;
    margin: 0.5rem 0;
}
.guide-section ul {
    padding-left: 1.2rem;
    margin: 0.5rem 0;
}

/* Download Section (on homepage) */
.download-section {
    max-width: 900px;
    width: 100%;
    padding: 2rem;
    border-top: 1px solid var(--border);
    margin-top: 1rem;
    padding-bottom: 4rem;
}
.download-section h2 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 1.2rem;
    text-align: center;
}
.download-cards {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}
.download-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.2rem;
    width: 260px;
    display: flex;
    flex-direction: column;
}
.download-card.current { border-color: var(--accent); }
.download-card h3 {
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 0.3rem;
    font-family: var(--font-mono);
}
.download-card .tags {
    display: inline-block;
    background: rgba(31, 111, 235, 0.13);
    color: var(--accent);
    font-size: 0.65rem;
    padding: 2px 7px;
    border-radius: 10px;
    margin-bottom: 0.7rem;
}
.download-card .desc {
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-bottom: 0.8rem;
    flex: 1;
}
.download-card .btn-dl {
    display: block;
    text-align: center;
    padding: 8px 0;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 500;
    text-decoration: none;
    background: #238636;
    color: #fff;
    margin-bottom: 0.5rem;
    transition: background 0.15s;
}
.download-card .btn-dl:hover { background: #2ea043; }
.download-card .curl-cmd {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 7px 40px 7px 10px;
    font-family: var(--font-mono);
    font-size: 0.66rem;
    color: #7ee787;
    position: relative;
    overflow-x: auto;
    white-space: nowrap;
}
.download-card .curl-cmd span { color: var(--text-secondary); }
.download-card .copy-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--bg-tertiary);
    border: none;
    color: var(--text-secondary);
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 0.6rem;
    cursor: pointer;
    font-family: var(--font-mono);
}
.download-card .copy-btn.copied { color: var(--success); }
.download-info {
    margin-top: 1.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: center;
}
.download-info code {
    background: var(--bg-tertiary);
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 0.73rem;
}

/* GitHub link */
.github-link {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    color: var(--text-muted);
    opacity: 0.7;
    transition: opacity 0.2s;
}
.github-link:hover { opacity: 1; color: var(--text-primary); }

/* Install section */
.install-section {
    max-width: 600px;
    margin: 3rem auto;
    padding: 2rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    text-align: center;
}
.install-section h2 {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}
.install-section p {
    color: var(--text-muted);
    font-size: 0.88rem;
    margin-bottom: 1rem;
}
.install-block {
    text-align: left;
    margin-bottom: 1.25rem;
}
.install-label {
    color: var(--text-primary);
    font-size: 0.82rem;
    font-weight: 600;
    margin: 0 0 0.4rem 0.25rem;
}
.install-sub {
    color: var(--text-muted);
    font-size: 0.74rem;
    margin: 0.4rem 0 0.25rem 0.25rem;
}
.install-cmd {
    display: flex;
    align-items: center;
    background: #1e1e2e;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin: 0 0 0.75rem 0;
    font-family: ui-monospace, monospace;
    font-size: 0.82rem;
    gap: 0.5rem;
}
.install-cmd code {
    flex: 1;
    color: #cdd6f4;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
}
.install-cmd code::-webkit-scrollbar { display: none; }
.install-cmd .copy-btn {
    flex-shrink: 0;
    background: #45475a;
    color: #cdd6f4;
    border: none;
    border-radius: 4px;
    padding: 0.25rem 0.6rem;
    font-size: 0.72rem;
    cursor: pointer;
    transition: background 0.2s;
}
.install-cmd .copy-btn:hover { background: #585b70; }
.install-cmd .copy-btn.copied { background: #40a02b; }

.install-note {
    color: var(--text-muted);
    font-size: 0.78rem;
    margin: 0;
}
