:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg-dark: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --border: rgba(148, 163, 184, 0.1);
    --text-main: #f8fafc;
    --text-dim: #94a3b8;
    --accent: #8b5cf6;
    --radius: 12px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
}

.app-container {
    padding-bottom: calc(65px + env(safe-area-inset-bottom));
    /* 为底部导航留出空间，减少留白 */
    min-height: 100vh;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border);
}

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

.logo-img {
    width: 32px;
    height: 32px;
    border-radius: 8px;
}

h1 {
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(135deg, #fff 0%, #a5b4fc 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
}

button {
    cursor: pointer;
    border: none;
    border-radius: var(--radius);
    transition: all 0.2s ease;
    font-weight: 600;
}

.primary-btn {
    background: var(--primary);
    color: white;
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.primary-btn:active,
.icon-btn:active,
.file-item:active {
    transform: scale(0.95);
    background: var(--primary-hover);
}

.icon-btn {
    background: rgba(148, 163, 184, 0.1);
    color: var(--text-main);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

main {
    padding: 1rem;
    max-width: 800px;
    margin: 0 auto;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.search-box input {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    outline: none;
    width: 100%;
}

.prompt-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.prompt-section h3 {
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.prompt-box {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    position: relative;
    overflow: hidden;
}

#prompt-template-display {
    font-size: 0.8125rem;
    color: var(--text-dim);
    white-space: pre-wrap;
    word-break: break-word;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    max-height: 400px;
    overflow-y: auto;
}

#pinned-section .file-item {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(139, 92, 246, 0.2) 100%);
    border: 1px solid rgba(99, 102, 241, 0.4);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

#pinned-section .file-icon {
    filter: drop-shadow(0 0 10px rgba(99, 102, 241, 0.6));
}

.section-title {
    font-size: 0.875rem;
    color: var(--text-dim);
    margin-bottom: 1rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
}

.file-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    animation: fadeIn 0.3s ease;
}

.file-item:active {
    background: rgba(255, 255, 255, 0.08);
}

.file-icon {
    font-size: 2rem;
}

.file-name {
    font-size: 0.875rem;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-dim);
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.3;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    z-index: 1000;
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-dark);
    width: 95%;
    max-width: 900px;
    height: 90vh;
    border-radius: 20px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.modal-content.sm {
    height: auto;
    max-width: 400px;
    padding: 1.5rem;
}

.modal-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.iframe-container {
    flex: 1;
    background: white;
    border-radius: 0 0 20px 20px;
    overflow: hidden;
}

iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    margin-top: 1rem;
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.file-label {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 0.5rem 1.5rem;
    border-radius: var(--radius);
    margin-top: 1rem;
    cursor: pointer;
}

.action-row {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.secondary-btn {
    background: rgba(148, 163, 184, 0.1);
    color: var(--text-main);
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
}

.auth-form {
    background: rgba(15, 23, 42, 0.3);
    padding: 1.25rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-top: 0.5rem;
}

.auth-form input {
    width: 100%;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border);
    color: white;
    padding: 0.75rem;
    border-radius: var(--radius);
    outline: none;
    margin-bottom: 0.5rem;
}

.auth-form input:focus {
    border-color: var(--primary);
}

.user-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(15, 23, 42, 0.3);
    padding: 1rem;
    border-radius: var(--radius);
}

.setting-item {
    margin-bottom: 2rem;
}

.setting-desc {
    font-size: 0.875rem;
    color: var(--text-dim);
    margin-bottom: 0.5rem;
}

#api-url-input {
    width: 100%;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border);
    color: white;
    padding: 0.75rem;
    border-radius: var(--radius);
    outline: none;
}

.storage-info {
    margin-top: 0.5rem;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(148, 163, 184, 0.1);
    border-radius: 4px;
    margin-top: 0.5rem;
    overflow: hidden;
}

.progress {
    height: 100%;
    background: var(--primary);
    width: 0%;
}

/* Tab Content Visibility */
.tab-content {
    padding: 1rem;
    max-width: 800px;
    margin: 0 auto;
}

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(20px);
    display: flex;
    justify-content: space-around;
    padding: 0.75rem 0.5rem;
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    z-index: 100;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    color: var(--text-dim);
    background: none;
    font-size: 0.75rem;
}

.nav-item.active {
    color: var(--primary);
}

.nav-item svg {
    width: 24px;
    height: 24px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.rotating svg {
    animation: rotate 1s linear infinite;
}

@media (max-width: 600px) {
    .file-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}