/* ===== Reset & Base ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #a5b4fc;
    --primary-bg: #eef2ff;
    --accent: #06b6d4;
    --accent-light: #67e8f9;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-light: #94a3b8;
    --border: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 20px rgba(99,102,241,0.1);
    --shadow-lg: 0 10px 40px rgba(99,102,241,0.15);
    --radius: 16px;
    --radius-sm: 10px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ===== Header ===== */
header {
    background: rgba(255,255,255,0.8);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: box-shadow var(--transition);
}

header.scrolled {
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.02em;
}

.logo i {
    font-size: 1.6rem;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

nav ul {
    display: flex;
    list-style: none;
    gap: 8px;
}

nav a {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 24px;
    transition: all var(--transition);
    font-size: 0.95rem;
}

nav a:hover, nav a.active {
    color: var(--primary);
    background: var(--primary-bg);
}

.mobile-menu-toggle {
    display: none;
    font-size: 1.5rem;
    color: var(--text);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    transition: background 0.2s;
}

.mobile-menu-toggle:hover {
    background: var(--border);
}

/* ===== Hero ===== */
.hero {
    text-align: center;
    padding: 48px 0 32px;
}

.hero h1 {
    font-size: 2.4rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.hero p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    max-width: 480px;
    margin: 0 auto;
}

/* ===== Tool Card ===== */
.tool-card, .result-card, .history-card, .about-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 28px 32px;
    margin-bottom: 28px;
    border: 1px solid var(--border);
    transition: box-shadow var(--transition);
}

.tool-card:hover, .result-card:hover {
    box-shadow: var(--shadow-md);
}

.tool-card-header, .result-header, .history-header {
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

.tool-card-header h2, .result-header h2, .history-header h2 {
    font-size: 1.3rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
}

.tool-card-header h2 i, .result-header h2 i, .history-header h2 i {
    color: var(--primary);
}

.tool-card-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    width: 100%;
    margin-top: 2px;
}

.badge {
    background: var(--primary-bg);
    color: var(--primary);
    font-weight: 600;
    font-size: 0.85rem;
    padding: 4px 14px;
    border-radius: 20px;
}

/* ===== Form ===== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 0.95rem;
    color: var(--text);
}

.form-group select,
.form-group input[type="number"],
.form-group input[type="text"],
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    background: var(--bg);
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
    font-family: inherit;
}

.form-group select:focus,
.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99,102,241,0.15);
}

.form-group textarea {
    resize: vertical;
    min-height: 120px;
}

.hidden {
    display: none !important;
}

/* ===== Buttons ===== */
.action-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    line-height: 1;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 12px rgba(99,102,241,0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(99,102,241,0.35);
}

.btn-primary:active {
    transform: scale(0.97);
}

.btn-secondary {
    background: var(--border);
    color: var(--text);
}

.btn-secondary:hover {
    background: #cbd5e1;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--border);
    color: var(--text-secondary);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-bg);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    color: #ef4444;
    background: #fef2f2;
}

.result-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* ===== Result Container ===== */
#result-container {
    min-height: 100px;
}

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

.empty-state i {
    font-size: 2.5rem;
    margin-bottom: 12px;
    display: block;
}

.chunk-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    margin-bottom: 12px;
    transition: all var(--transition);
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.chunk-item:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow-sm);
}

.chunk-index {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
}

.chunk-content {
    flex: 1;
    word-break: break-word;
    white-space: pre-wrap;
    line-height: 1.7;
    font-size: 0.95rem;
}

.chunk-copy-btn {
    flex-shrink: 0;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 34px;
    height: 34px;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chunk-copy-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ===== History ===== */
.history-card {
    background: var(--card-bg);
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    gap: 12px;
    flex-wrap: wrap;
}

.history-item:last-child {
    border-bottom: none;
}

.history-info {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.history-mode {
    background: var(--primary-bg);
    color: var(--primary);
    padding: 2px 12px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
}

.history-preview {
    color: var(--text-secondary);
    font-size: 0.9rem;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-time {
    color: var(--text-light);
    font-size: 0.8rem;
    white-space: nowrap;
}

.history-empty {
    text-align: center;
    padding: 20px;
    color: var(--text-light);
}

/* ===== About & Footer ===== */
.about-section {
    text-align: center;
    background: linear-gradient(135deg, var(--primary-bg), #ffffff);
    border: 1px solid var(--primary-light);
}

.about-section h2 {
    font-size: 1.3rem;
    margin-bottom: 12px;
    color: var(--primary);
}

.about-section p {
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.7;
}

footer {
    text-align: center;
    padding: 28px 0;
    color: var(--text-light);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
    background: var(--card-bg);
    margin-top: 20px;
}

/* ===== Toast Notification ===== */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text);
    color: white;
    padding: 14px 28px;
    border-radius: 12px;
    font-weight: 500;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 999;
    pointer-events: none;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

.toast i {
    font-size: 1.2rem;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .header-content {
        height: 56px;
    }

    nav ul {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 56px;
        left: 0;
        right: 0;
        background: rgba(255,255,255,0.98);
        backdrop-filter: blur(16px);
        border-bottom: 1px solid var(--border);
        padding: 16px 20px;
        box-shadow: var(--shadow-md);
    }

    nav ul.open {
        display: flex;
    }

    .mobile-menu-toggle {
        display: block;
    }

    .hero h1 {
        font-size: 1.8rem;
    }

    .hero p {
        font-size: 1rem;
    }

    .tool-card, .result-card, .history-card, .about-section {
        padding: 20px;
        margin-bottom: 20px;
    }

    .action-buttons {
        flex-direction: column;
    }

    .action-buttons .btn {
        width: 100%;
        justify-content: center;
    }

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

    .result-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .history-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .history-info {
        width: 100%;
    }

    .history-preview {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 14px;
    }

    .hero h1 {
        font-size: 1.5rem;
    }

    .chunk-item {
        flex-direction: column;
        align-items: stretch;
    }

    .chunk-copy-btn {
        align-self: flex-end;
    }
}