/* ============================================
   LocalShareServer v3 鈥?Design System
   Indigo/Slate Palette
   ============================================ */

/* ---- Web Font (代码雨显示字体) ---- */
@font-face {
    font-family: "JetBrains Mono";
    src: url("/fonts/JetBrainsMono.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

/* ---- Primitives ---- */
:root {
    --indigo-50: #eef2ff;
    --indigo-100: #e0e7ff;
    --indigo-200: #c7d2fe;
    --indigo-300: #a5b4fc;
    --indigo-400: #818cf8;
    --indigo-500: #6366f1;
    --indigo-600: #4f46e5;
    --indigo-700: #4338ca;
    --indigo-800: #3730a3;
    --indigo-900: #312e81;

    --slate-50: #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-300: #cbd5e1;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-600: #475569;
    --slate-700: #334155;
    --slate-800: #1e293b;
    --slate-900: #0f172a;

    --emerald-50: #ecfdf5;
    --emerald-500: #10b981;
    --emerald-600: #059669;

    --amber-50: #fffbeb;
    --amber-500: #f59e0b;
    --amber-600: #d97706;

    --rose-50: #fff1f2;
    --rose-500: #f43f5e;
    --rose-600: #e11d48;

    --cyan-400: #22d3ee;
    --violet-400: #a78bfa;
}

/* ---- Semantic Tokens (Light) ---- */
:root {
    --color-primary: var(--indigo-600);
    --color-primary-hover: var(--indigo-700);
    --color-primary-light: var(--indigo-50);
    --color-primary-ring: rgba(79, 70, 229, 0.3);

    --color-bg: var(--slate-50);
    --color-surface: #ffffff;
    --color-surface-hover: var(--slate-50);
    --color-surface-elevated: #ffffff;
    --color-surface-card: #ffffff;

    --color-text: var(--slate-900);
    --color-text-secondary: var(--slate-500);
    --color-text-muted: var(--slate-400);
    --color-text-inverse: #ffffff;

    --color-border: var(--slate-200);
    --color-border-light: var(--slate-100);
    --color-border-hover: var(--indigo-300);

    --color-success: var(--emerald-500);
    --color-success-bg: var(--emerald-50);
    --color-warning: var(--amber-500);
    --color-warning-bg: var(--amber-50);
    --color-error: var(--rose-500);
    --color-error-bg: var(--rose-50);
    --color-error: var(--rose-600);
    --color-error-bg: var(--rose-50);

    --color-encrypted: var(--violet-400);
    --color-progress: linear-gradient(135deg, var(--indigo-500), var(--cyan-400));

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-pill: 12px;

    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", sans-serif;
    --font-mono: "SF Mono", "Fira Code", "Cascadia Code", "JetBrains Mono", monospace;

    --transition-fast: 0.15s ease;
    --transition-base: 0.25s ease;
    --transition-smooth: 0.3s cubic-bezier(0.16, 1, 0.3, 1);

    --max-width: 2500px;
    --header-height: 60px;
}

/* ---- Dark Mode ---- */
@media (prefers-color-scheme: dark) {
    :root {
        --color-bg: #0a0c10;
        --color-surface: var(--slate-800);
        --color-surface-hover: var(--slate-700);
        --color-surface-elevated: var(--slate-800);
        --color-surface-card: var(--slate-800);

        --color-text: var(--slate-100);
        --color-text-secondary: var(--slate-400);
        --color-text-muted: var(--slate-500);

        --color-border: var(--slate-700);
        --color-border-light: var(--slate-700);

        --color-primary: var(--indigo-400);
        --color-primary-hover: var(--indigo-300);

        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
        --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
        --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
        --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.4);
    }
}

/* ---- Reset & Base ---- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    color: var(--color-text);
    background: var(--color-bg);
    min-height: 100vh;
    line-height: 1.6;
}

/* Subtle diagonal gradient background + 顶部蓝紫氛围光晕（覆盖标题栏与 hero 顶部，避免断层） */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 70% 55% at 50% 0%, rgba(80, 130, 210, 0.10), transparent 68%),
        linear-gradient(
            135deg,
            var(--indigo-50) 0%,
            transparent 40%,
            transparent 60%,
            var(--indigo-50) 100%
        );
    pointer-events: none;
    z-index: -1;
}

@media (prefers-color-scheme: dark) {
    body::before {
        background:
            radial-gradient(ellipse 70% 55% at 50% 0%, rgba(80, 130, 210, 0.10), transparent 68%),
            linear-gradient(
                135deg,
                rgba(79, 70, 229, 0.06) 0%,
                transparent 40%,
                transparent 60%,
                rgba(79, 70, 229, 0.04) 100%
            );
    }
}

/* ---- Code Rain Background ---- */
canvas[data-rain] {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    opacity: 0.4; /* 浅色模式：克制，普通叠加 */
}
@media (prefers-color-scheme: dark) {
    canvas[data-rain] {
        mix-blend-mode: screen; /* 暗色模式：让雨"发光"而非遮盖 */
        opacity: 1;
    }
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img, svg { display: block; max-width: 100%; }

code, pre {
    font-family: var(--font-mono);
    font-size: 0.875em;
}

/* ---- Utilities ---- */
.hidden { display: none !important; }
.hidden-force { display: none !important; }

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
}
.modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}
.modal-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    max-width: 90vw;
    width: 380px;
    box-shadow: var(--shadow-xl);
    transform: translateY(8px);
    transition: transform 0.18s ease;
}
.modal-overlay.show .modal-card {
    transform: translateY(0);
}
.modal-message {
    font-size: 0.9rem;
    color: var(--color-text);
    line-height: 1.6;
    white-space: pre-wrap;
    margin-bottom: 18px;
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ---- App Shell ---- */
.app-shell {
    max-width: min(75vw, 1200px);
    margin: 0 auto;
    padding: 0 20px;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 4px;
    margin-bottom: 8px;
}

.app-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-text);
    text-decoration: none;
}

.app-logo:hover { text-decoration: none; }

.app-logo-icon {
    width: 32px;
    height: 32px;
    background: var(--color-primary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    font-weight: 700;
}

.app-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ---- Navigation Tabs ---- */
.app-nav {
    position: relative;
}

.nav-tabs {
    display: flex;
    gap: 2px;
    background: var(--color-surface);
    padding: 4px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border-light);
}

.nav-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-fast);
    white-space: nowrap;
    text-decoration: none;
}

.nav-tab:hover {
    background: var(--color-surface-hover);
    color: var(--color-text);
    text-decoration: none;
}

.nav-tab--active {
    color: var(--color-primary);
    font-weight: 600;
}

.nav-tab--active:hover {
    color: var(--color-primary-hover);
}

.nav-tab svg {
    width: 16px;
    height: 16px;
}

/* ---- Nav Indicator (sliding underline) ---- */
.nav-indicator {
    position: absolute;
    bottom: 0;
    height: 2px;
    background: var(--color-primary);
    border-radius: 2px 2px 0 0;
    transition: left 0.28s cubic-bezier(0.4, 0, 0.2, 1), width 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    z-index: 2;
}

/* ---- Page Content ---- */
#page-content {
    animation: page-fade-in 0.3s ease;
}

@keyframes page-fade-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---- Typography ---- */
.page-title {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 6px;
}

.page-subtitle {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    margin-bottom: 24px;
}

.section-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ---- Card ---- */
.card {
    background: var(--color-surface-card);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition-base);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card--elevated {
    box-shadow: var(--shadow-md);
}

.card--compact {
    padding: 16px;
}

.card + .card {
    margin-top: 16px;
}

/* ---- Home Page ---- */
.home-hero {
    text-align: center;
    padding: 48px 20px 32px;
}

.home-hero h1 {
    font-size: 2.2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--indigo-600), var(--indigo-400));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

@media (prefers-color-scheme: dark) {
    .home-hero h1 {
        background: linear-gradient(135deg, var(--indigo-300), var(--indigo-100));
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
    }
}

.home-hero p {
    font-size: 1rem;
    color: var(--color-text-secondary);
    margin-bottom: 4px;
}

.home-stats {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.home-stat {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    color: var(--color-text-secondary);
}

.home-stat svg {
    width: 16px;
    height: 16px;
    color: var(--color-primary);
}

/* ---- Home Status Panel ---- */
.home-status-panel {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin: 8px auto 24px;
    padding: 12px 24px;
    max-width: 480px;
    border: 1px solid var(--color-border-light);
    border-radius: 14px;
    background: var(--color-surface);
}
.home-status-panel[hidden] { display: none; }
.home-status-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}
.home-status-label {
    font-size: 12px;
    color: var(--color-text-muted);
    letter-spacing: 0.5px;
}
.home-status-value {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.2;
}
.home-status-divider {
    width: 1px;
    height: 28px;
    background: var(--color-border-light);
}
.home-status-value[data-level="very_low"]  { color: var(--emerald-500); }
.home-status-value[data-level="low"]       { color: var(--emerald-600); }
.home-status-value[data-level="medium"]    { color: var(--amber-500); }
.home-status-value[data-level="high"]      { color: var(--amber-600); }
.home-status-value[data-level="very_high"] { color: var(--rose-600); }

/* ---- Entry Grid (Pill Buttons) ---- */
.entry-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    padding: 0 12px;
    max-width: 800px;
    margin: 0 auto;
}

/* Extra-wide 4-column pill grid for home */
.entry-grid--4 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    padding: 0 8px;
    max-width: 960px;
    margin: 0 auto;
}

/* Responsive: 4-col 鈫?3-col 鈫?2-col */
@media (max-width: 900px) {
    .entry-grid--4 {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
        max-width: 700px;
    }
}
@media (max-width: 600px) {
    .entry-grid--4 {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
}

/* ---- Pill Button ---- */
.btn--pill {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 1.6em 1.5em;
    font-size: 13px;
    letter-spacing: 0.5px;
    font-weight: 600;
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-sm);
    transition: var(--transition-smooth);
    cursor: pointer;
    outline: none;
    text-decoration: none;
    font-family: inherit;
    text-transform: uppercase;
}

.btn--pill:hover {
    background: var(--color-primary);
    border-color: var(--color-primary);
    box-shadow: 0 12px 20px -4px rgba(79, 70, 229, 0.3);
    color: var(--color-text-inverse);
    transform: translateY(-6px);
    text-decoration: none;
}

.btn--pill:active {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px -2px rgba(79, 70, 229, 0.3);
}

.btn--pill svg {
    width: 32px;
    height: 32px;
    transition: var(--transition-smooth);
}

.btn--pill:hover svg {
    transform: scale(1.15);
}

/* ---- Standard Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn--primary {
    background: var(--color-primary);
    color: white;
}

.btn--primary:hover:not(:disabled) {
    background: var(--color-primary-hover);
    box-shadow: var(--shadow-md);
}

/* ---- Outline Button (Refined small) ---- */
.btn--outline {
    background: transparent;
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
    padding: 7px 14px;
}

.btn--outline:hover:not(:disabled) {
    border-color: var(--color-primary);
    background: rgba(79, 70, 229, 0.05);
    color: var(--color-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(79, 70, 229, 0.08);
}

.btn--outline:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: none;
}

/* ---- Ghost Button ---- */
.btn--ghost {
    background: transparent;
    color: var(--color-text-secondary);
    border: none;
    padding: 7px 12px;
}

.btn--ghost:hover:not(:disabled) {
    background: var(--color-surface-hover);
    color: var(--color-text);
}

/* ---- Danger Button ---- */
.btn--danger {
    color: var(--color-error);
    border-color: var(--color-error);
}

.btn--danger:hover:not(:disabled) {
    background: var(--color-error-bg);
    border-color: var(--color-error);
    color: var(--color-error);
    box-shadow: 0 4px 8px rgba(244, 63, 94, 0.15);
}

/* ---- Outline Primary Button (transparent + themed, with interaction) ---- */
.btn--outline-primary {
    background: transparent;
    color: var(--color-primary);
    border: 1px solid var(--color-primary);
    min-height: 52px;
}

.btn--outline-primary:hover:not(:disabled) {
    background: rgba(79, 70, 229, 0.08);
    color: var(--color-primary);
    border-color: var(--color-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(79, 70, 229, 0.12);
}

.btn--outline-primary:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: none;
}

/* ---- Button Sizes ---- */
.btn--sm {
    padding: 5px 10px;
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
}

.btn--lg {
    padding: 12px 28px;
    font-size: 0.9rem;
}

/* ---- Glass Button (for dark card backgrounds) ---- */
.btn--glass {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: inherit;
    color: rgba(255, 255, 255, 0.85);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-base);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
}

.btn--glass:hover {
    border-color: rgba(255, 255, 255, 0.5);
    background: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0.1),
        rgba(255, 255, 255, 0.25),
        rgba(255, 255, 255, 0.35)
    );
    box-shadow: 0 5px rgba(255, 255, 255, 0.3);
    transform: translateY(-5px);
    color: white;
    text-decoration: none;
}

.btn--glass:active {
    transform: translateY(1px);
    box-shadow: none;
}

.btn--glass svg {
    width: 16px;
    height: 16px;
}

/* ---- Form Elements ---- */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    font-size: 0.88rem;
    font-family: var(--font-sans);
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
    outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-ring);
}

.form-input::placeholder {
    color: var(--color-text-muted);
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

.form-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: 4px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-row--3 {
    grid-template-columns: 1fr 1fr 1fr;
}

@media (max-width: 600px) {
    .form-row,
    .form-row--3 {
        grid-template-columns: 1fr;
    }
}

/* ---- Checkbox ---- */
.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--color-primary);
    cursor: pointer;
}

.checkbox-group label {
    font-size: 0.88rem;
    cursor: pointer;
}

.checkbox-group--disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* ---- Upload Area (Drag & Drop) ---- */
.upload-area {
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-lg);
    padding: 40px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color var(--transition-fast), border-style var(--transition-fast);
    background: var(--color-surface-card);
    box-sizing: border-box;
}

.upload-area:hover,
.upload-area:focus-within,
.upload-area.dragover {
    border-color: var(--color-primary);
}

.upload-area:focus-within,
.upload-area.dragover,
.upload-area.has-file {
    border-style: solid;
}

.upload-icon {
    display: flex;
    justify-content: center;
    margin-bottom: 12px;
    color: var(--color-text-muted);
    transition: color var(--transition-fast);
}

.upload-area:hover .upload-icon,
.upload-area.dragover .upload-icon {
    color: var(--color-primary);
}

.upload-area p {
    font-size: 0.88rem;
    color: var(--color-text-secondary);
    margin-bottom: 4px;
}

.upload-area p strong {
    color: var(--color-text);
}

/* ---- Progress Bar ---- */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--color-border-light);
    border-radius: 99px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: var(--color-progress);
    border-radius: 99px;
    transition: width 0.3s ease;
    width: 0%;
}

/* 滑动进度条（加密/解密阶段复用上传/下载进度条，蓝色滚动效果，类似 Windows 不可跟踪操作） */
.progress-fill--sliding {
    width: 25% !important;
    background: linear-gradient(90deg, #3B82F6, #2563EB, #1D4ED8) !important;
    animation: slide-progress 2s linear infinite;
    transition: none !important;
}
@keyframes slide-progress {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(400%); }
}

.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    color: var(--color-text-secondary);
}

.progress-speed {
    color: var(--color-text-muted);
}

/* ---- Encrypt/Decrypt Progress ---- */
.encrypt-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--color-primary-light);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    color: var(--color-primary);
}

.encrypt-progress .spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---- Upload Result ---- */
.upload-result {
    background: var(--color-surface-card);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-top: 12px;
    box-shadow: var(--shadow-sm);
}

.upload-result h3 {
    color: var(--color-success);
    font-size: 0.95rem;
    margin-bottom: 8px;
}

.result-field {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 0.82rem;
}

.result-field label {
    font-weight: 600;
    color: var(--color-text-secondary);
    min-width: 60px;
}

.result-field input {
    flex: 1;
    padding: 6px 10px;
    font-size: 0.82rem;
    font-family: var(--font-mono);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text);
}

/* ---- File Info (Receive) ---- */
.file-info {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 16px;
}

.file-info-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 16px;
    font-size: 0.85rem;
}

.file-info-label {
    color: var(--color-text-secondary);
    font-weight: 500;
}

.file-info-value {
    color: var(--color-text);
}

/* ---- Status Badges ---- */
.status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: 99px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.status--success {
    background: var(--color-success-bg);
    color: var(--color-success);
}

.status--warning {
    background: var(--color-warning-bg);
    color: var(--color-warning);
}

.status--error {
    background: var(--color-error-bg);
    color: var(--color-error);
}

.status--info {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

/* ---- Notification ---- */
.notification {
    position: fixed;
    top: calc(var(--header-height, 60px) + 16px);
    right: 16px;
    z-index: 9999;
    padding: 14px 20px;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    transform: translateX(120%);
    opacity: 0;
    transition: var(--transition-smooth);
    max-width: 380px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.notification.show {
    transform: translateX(0);
    opacity: 1;
}

.notification.success {
    background: var(--color-success);
    color: white;
}

.notification.error {
    background: var(--color-error);
    color: white;
}

.notification.warning {
    background: var(--color-warning);
    color: white;
}

.notification.info {
    background: var(--color-primary);
    color: white;
}

@media (max-width: 768px) {
    .notification {
        /* 移动端导航栏为多行 column 布局（约 100px），下移避免遮挡 */
        top: 112px;
    }
}

@media (max-width: 480px) {
    .notification {
        left: 16px;
        right: 16px;
        max-width: none;
    }
}

/* ---- Tables ---- */
.table-container {
    overflow-x: auto;
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

thead {
    background: var(--color-surface-hover);
}

th {
    text-align: left;
    padding: 10px 14px;
    font-weight: 600;
    font-size: 0.78rem;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

td {
    padding: 8px 14px;
    border-bottom: 1px solid var(--color-border-light);
    vertical-align: middle;
}

tbody tr {
    transition: var(--transition-fast);
}

tbody tr:hover {
    background: var(--color-surface-hover);
}

tbody tr:last-child td {
    border-bottom: none;
}

.file-actions {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
}

.file-actions .btn {
    font-size: 0.72rem;
    padding: 4px 10px;
}

.file-id-code {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    background: var(--color-surface-hover);
    padding: 2px 6px;
    border-radius: 3px;
    color: var(--color-text);
    cursor: help;
}

.empty-message {
    text-align: center;
    padding: 24px !important;
    color: var(--color-text-muted);
    font-style: italic;
}

/* ---- Connections List ---- */
.connections-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 400px;
    overflow-y: auto;
}

.connection-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--color-surface);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

.connection-item:hover {
    border-color: var(--color-border);
    box-shadow: var(--shadow-sm);
}

.connection-info {
    flex: 1;
    min-width: 0;
}

.connection-main {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
}

.connection-type {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 1px 8px;
    border-radius: 99px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.connection-type--upload { background: #dbeafe; color: #2563eb; }
.connection-type--admin { background: var(--color-error-bg); color: var(--color-error); }
.connection-type--user { background: var(--color-success-bg); color: var(--color-success); }

.connection-ip {
    font-size: 0.82rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.connection-meta {
    display: flex;
    gap: 12px;
    font-size: 0.72rem;
    color: var(--color-text-muted);
}

.connection-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 120px;
}

.connection-progress-bar {
    flex: 1;
    height: 4px;
    background: var(--color-border-light);
    border-radius: 99px;
    overflow: hidden;
}

.connection-progress-fill {
    height: 100%;
    background: var(--color-primary);
    border-radius: 99px;
    transition: width 0.5s ease;
}

.connection-progress-fill--active {
    background: var(--color-progress);
}

.connection-progress-fill--transition {
    transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.connection-progress-text {
    font-size: 0.72rem;
    color: var(--color-text-muted);
    min-width: 30px;
    text-align: right;
}

.connection-actions {
    flex-shrink: 0;
}

.connection-btn {
    padding: 4px 10px;
    font-size: 0.72rem;
    font-weight: 600;
    font-family: inherit;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: var(--color-surface);
    color: var(--color-text-secondary);
    transition: var(--transition-fast);
}

.connection-btn:hover {
    border-color: var(--color-error);
    color: var(--color-error);
    background: var(--color-error-bg);
}

.connections-empty {
    text-align: center;
    padding: 20px;
    color: var(--color-text-muted);
}

/* ---- Logs ---- */
.logs-container {
    background: var(--slate-900);
    color: var(--slate-100);
    border-radius: var(--radius-md);
    padding: 16px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    line-height: 1.6;
    max-height: 400px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

/* ---- Auth Pages ---- */
.auth-form {
    max-width: 400px;
    margin: 0 auto;
}

.auth-actions {
    display: flex;
    gap: 8px;
    margin-top: 20px;
}

.auth-actions .btn {
    flex: 1;
}

.auth-links {
    text-align: center;
    margin-top: 16px;
    font-size: 0.82rem;
    color: var(--color-text-secondary);
}

.auth-links a {
    font-weight: 600;
}

/* ---- Account Page ---- */
.account-info {
    display: grid;
    gap: 8px 16px;
}

.account-info-row {
    display: flex;
    gap: 8px;
    font-size: 0.88rem;
    padding: 8px 0;
    border-bottom: 1px solid var(--color-border-light);
}

.account-info-row:last-child {
    border-bottom: none;
}

.account-label {
    min-width: 100px;
    font-weight: 600;
    color: var(--color-text-secondary);
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        height: auto;
        padding: 12px 0;
        gap: 8px;
    }

    .nav-tabs {
        flex-wrap: wrap;
        justify-content: center;
    }

    .nav-tab {
        font-size: 0.75rem;
        padding: 5px 10px;
    }

    .nav-tab svg {
        display: none;
    }

    .home-hero {
        padding: 28px 16px 20px;
    }

    .home-hero h1 {
        font-size: 1.5rem;
    }

    .entry-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 10px;
    }

    .btn--pill {
        padding: 1.2em 0.8em;
        font-size: 11px;
        border-radius: 20px;
    }

    .card {
        padding: 16px;
    }

    .page-title {
        font-size: 1.3rem;
    }

    .table-container {
        margin: 0 -16px;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    th, td {
        padding: 8px;
        font-size: 0.75rem;
    }

    .connection-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .connection-progress {
        min-width: 0;
        width: 100%;
    }

    .home-stats {
        gap: 12px;
    }
}

@media (max-width: 480px) {
    .entry-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .btn--pill {
        padding: 1em 0.5em;
        border-radius: 16px;
    }

    .btn--pill svg {
        width: 24px;
        height: 24px;
    }

    .file-actions {
        flex-direction: column;
    }
}

/* ---- Search Box ---- */
.search-box {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    background: var(--color-bg);
    min-width: 100px;
    max-width: 240px;
    transition: border-color 0.15s ease;
    height: 30px;
    box-sizing: border-box;
}
.search-box:focus-within {
    border-color: var(--color-primary);
}
.search-box__icon {
    color: var(--color-text-muted);
    flex-shrink: 0;
}
.search-box__input {
    border: none;
    background: transparent;
    outline: none;
    flex: 1;
    min-width: 60px;
    max-width: 100%;
    font-size: 13px;
    font-family: inherit;
    color: var(--color-text);
    padding: 0;
    margin: 0;
    height: 100%;
}
.search-box__input::placeholder {
    color: var(--color-text-muted);
}

/* ---- HTMX Loading Indicator ---- */
.htmx-request {
    opacity: 0.7;
    transition: opacity 0.2s;
}

.htmx-indicator {
    opacity: 0;
    transition: opacity 0.2s;
}

.htmx-request .htmx-indicator {
    opacity: 1;
}

/* All page content width limited to 75% */
#page-content {
    max-width: 75vw;
    margin: 0 auto;
    padding: 0 20px;
}

.card {
    max-width: 100%;
}

/* 管理后台统计面板大小统一 */
.admin-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
    align-items: stretch;
}

.admin-stat-card {
    text-align: center;
    padding: 12px !important;
    min-height: 80px !important;
    height: 80px !important;
    max-height: 80px !important;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
    gap: 8px;
    overflow: hidden;
    margin: 0 !important;
    margin-top: 0 !important;
}

.admin-stat-card--neutral .admin-stat-value {
    color: inherit;
}

.admin-stat-label {
    font-size: 0.72rem;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin: 0;
    line-height: 1.2;
    height: 1.2rem;
    min-height: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.admin-stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 1.6rem;
    min-height: 1.6rem;
}

/* 兼容旧类名 */
.admin-stats-panel {
    padding: 16px 12px;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* 文件列表中的按钮边框颜色更深 */
.file-actions .btn--outline {
    border-color: var(--slate-400) !important;
    border-width: 1.5px;
}

.file-actions .btn--outline:hover {
    border-color: var(--indigo-500) !important;
    background: var(--indigo-50);
}

/* 表格行hover时按钮保持可见 */
.table-container tr:hover .file-actions .btn--outline {
    border-color: var(--slate-500) !important;
}

/* 兼容旧类名 */
.btn--download,
.table-action-btn.download {
    border-color: var(--slate-400) !important;
    border-width: 1.5px;
}

.btn--download:hover,
.table-action-btn.download:hover {
    border-color: var(--indigo-500) !important;
    background: var(--indigo-50);
}

.table-container tr:hover .btn--download,
.table-container tr:hover .table-action-btn.download {
    border-color: var(--slate-500) !important;
}

