:root {
    /* 核心色板 - Modern Palette */
    --primary-hue: 210;
    /* Blue */
    --primary-sat: 90%;
    --primary-lit: 58%;

    --color-primary: hsl(var(--primary-hue), var(--primary-sat), var(--primary-lit));
    --color-primary-hover: hsl(var(--primary-hue), var(--primary-sat), 48%);
    --color-primary-active: hsl(var(--primary-hue), var(--primary-sat), 40%);
    --color-primary-glow: hsla(var(--primary-hue), var(--primary-sat), var(--primary-lit), 0.3);

    /* Dark Mode Variables (Default base) */
    --bg-body: #0f172a;
    /* 深蓝黑背景 */
    --bg-card: #1e293b;
    /* 卡片背景 */
    --bg-card-hover: #263346;
    --bg-input: #0f172a;
    --border-color: #334155;
    --border-hover: #475569;

    --text-main: #f1f5f9;
    --text-muted: #94a3b8;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.3), 0 4px 6px -4px rgb(0 0 0 / 0.3);

    /* Specific Colors */
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    --code-bg: #0d1117;

    /* Chat Colors */
    --chat-user-bg: var(--color-primary);
    --chat-user-text: #ffffff;
    --chat-ai-bg: #334155;
    --chat-ai-text: #f1f5f9;

    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;

    --header-height: 70px;
    --nav-width-desktop: 450px;
}

body.light-theme {
    --bg-body: #f8fafc;
    /* 柔和灰白 */
    --bg-card: #ffffff;
    --bg-card-hover: #fcfcfc;
    --bg-input: #f1f5f9;
    --border-color: #e2e8f0;
    --border-hover: #cbd5e1;

    --text-main: #0f172a;
    --text-muted: #64748b;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

    --chat-ai-bg: #f1f5f9;
    --chat-ai-text: #0f172a;
    --code-bg: #f1f5f9;
}

body.mobile-menu-open {
    overflow: hidden;
}

/* Mobile Menu Overlay */
.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: transparent; /* 不再给页面叠加灰色遮罩 */
    z-index: 900; /* 低于导航及头部，确保菜单和按钮可点击 */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    pointer-events: none;
}

.mobile-menu-overlay.is-active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* 确保导航栏在遮罩层之上 */
@media (max-width: 768px) {
    nav {
        z-index: 1000 !important; /* 确保导航栏在遮罩层之上 */
    }
}

/* --- Global Styles --- */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    margin: 0;
    height: 100%;
    line-height: 1.6;
    transition: background-color 0.4s ease, color 0.4s ease;
    overflow-y: scroll;
    /* Prevent shift on modal open */
}

/* Smooth Scrolling */
html {
    scroll-behavior: smooth;
    height: 100%;
}

/* Main Layout */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- Header --- */
header {
    position: sticky;
    top: 10px;
    z-index: 1200; /* 高于移动遮罩层，避免遮挡菜单/主题按钮 */
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: 30px;
    transition: all 0.3s ease;
}

/* Glassmorphism effect for header if supported */
@supports (backdrop-filter: blur(12px)) {
    header {
        background: color-mix(in srgb, var(--bg-card) 85%, transparent);
    }
}

.header-content {
    height: var(--header-height);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    background: linear-gradient(135deg, var(--color-primary) 0%, #8b5cf6 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 12px;
    letter-spacing: -0.5px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

header h1 i {
    -webkit-text-fill-color: initial;
    /* Icon keeps its color or uses gradient */
    color: var(--color-primary);
    font-size: 1.2rem;
}

/* Navigation */
nav {
    display: flex;
    gap: 5px;
    background: var(--bg-input);
    padding: 5px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.nav-link {
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-link:hover {
    color: var(--text-main);
    background-color: rgba(148, 163, 184, 0.1);
}

.nav-link.active {
    background-color: var(--bg-card);
    color: var(--color-primary);
    box-shadow: var(--shadow-sm);
    font-weight: 600;
}

/* Clear All Button */
.clear-all-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    width: 42px;
    height: 42px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-left: 15px;
}

.clear-all-btn:hover {
    background: var(--bg-input);
    color: var(--color-danger);
    border-color: var(--color-danger);
    transform: scale(1.1);
    box-shadow: 0 0 15px -3px var(--color-danger);
}

/* Theme Toggle */
.theme-toggle {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    width: 42px;
    height: 42px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-left: 15px;
}

.theme-toggle:hover {
    background: var(--bg-input);
    color: var(--color-warning);
    border-color: var(--color-warning);
    transform: rotate(15deg);
    box-shadow: 0 0 15px -3px var(--color-warning);
}

/* Menu Toggle */
.menu-toggle {
    display: none;
    /* Hidden on desktop */
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    width: 42px;
    height: 42px;
    border-radius: 50%;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 1001;
    /* Above nav */
}

.menu-toggle:hover {
    color: var(--color-primary);
    border-color: var(--color-primary);
}


/* --- Main Content --- */
main {
    flex: 1;
    animation: fadeIn 0.6s ease-out;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

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

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

/* Tool Section Cards */
.tool-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 40px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.tool-section:hover {
    border-color: var(--border-hover);
}

.tool-section h2 {
    margin-top: 0;
    font-size: 1.75rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 20px;
    margin-bottom: 30px;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 12px;
}

.tool-section h2 i {
    color: var(--color-primary);
    background: rgba(59, 130, 246, 0.1);
    /* Subtle bg for icon */
    padding: 10px;
    border-radius: 10px;
    font-size: 0.9em;
}

/* --- Inputs & Forms --- */
input[type="text"],
textarea,
select {
    width: 100%;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
}

textarea {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    line-height: 1.5;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-glow), 0 4px 12px rgba(59, 130, 246, 0.15);
    background-color: var(--bg-card);
    transform: translateY(-1px);
}

select:hover {
    border-color: var(--border-hover);
    background-color: var(--bg-card);
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* --- Buttons --- */
button {
    background-color: var(--bg-input);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.95rem;
    position: relative;
    overflow: hidden;
    /* Important for scan lines */
}

button:hover {
    background-color: var(--bg-card-hover);
    border-color: var(--text-muted);
    transform: translateY(-1px);
}

button:active {
    transform: translateY(0);
}

.button-primary {
    background: var(--color-primary);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 10px 18px rgba(59, 130, 246, 0.28);
}

.button-primary:hover {
    background: var(--color-primary-hover);
    box-shadow: 0 14px 24px rgba(59, 130, 246, 0.35);
    color: #fff;
}

.api-ghost-btn {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(59, 130, 246, 0.08));
    border: 1px solid rgba(59, 130, 246, 0.35);
    color: var(--color-primary);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.api-ghost-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(59, 130, 246, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.4s, height 0.4s;
}

.api-ghost-btn:hover::before {
    width: 200px;
    height: 200px;
}

.api-ghost-btn.subtle {
    background: transparent;
    border-style: dashed;
    border-color: var(--border-color);
    color: var(--text-muted);
}

.api-ghost-btn.subtle:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: rgba(59, 130, 246, 0.05);
}

.api-ghost-btn:hover {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(59, 130, 246, 0.12));
    border-color: rgba(59, 130, 246, 0.6);
    color: var(--color-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

/* --- API Debugger Layout --- */
#api-debugger {
    display: flex;
    flex-direction: column;
    gap: 32px;
    animation: fadeInUp 0.5s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.api-debugger-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    padding: 8px 0;
}

.api-debugger-heading h2 {
    margin: 0;
    border-bottom: none;
    padding-bottom: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.api-debugger-heading h2 i {
    background: linear-gradient(135deg, var(--color-primary), #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 1.1em;
}

.section-subtitle {
    margin: 8px 0 0;
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.6;
}

.api-debugger-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.api-vertical-stack {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.api-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-height: 100%;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.api-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--color-primary), #8b5cf6, var(--color-primary));
    background-size: 200% 100%;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.api-panel:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.api-panel:hover::before {
    opacity: 1;
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--border-color);
    transition: border-color 0.3s ease;
}

.api-panel:hover .panel-header {
    border-bottom-color: var(--color-primary);
}

.panel-header h3 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-main);
}

.panel-header h3 i {
    color: var(--color-primary);
    font-size: 1.1em;
    background: rgba(59, 130, 246, 0.1);
    padding: 8px;
    border-radius: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.panel-collapse-btn {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    color: var(--text-muted);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.panel-collapse-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--color-primary);
    color: var(--color-primary);
    transform: scale(1.05);
}

.panel-collapse-btn i {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.api-panel.collapsed .panel-collapse-btn i {
    transform: rotate(180deg);
}

.panel-body {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.api-panel.collapsed .panel-body {
    display: none;
}

.request-panel {
    position: relative;
}

.api-request-bar {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 20px;
    padding: 20px;
    background: var(--bg-input);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.api-request-bar:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-sm);
}

.api-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.api-field label {
    margin-bottom: 0;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 6px;
}

.api-field label::before {
    content: '';
    width: 3px;
    height: 16px;
    background: var(--color-primary);
    border-radius: 2px;
}

.api-field select,
.api-field input {
    transition: all 0.2s ease;
}

.api-field select:focus,
.api-field input:focus {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.api-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--bg-input) 0%, var(--bg-card) 100%);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.api-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(59, 130, 246, 0.05), transparent);
    transition: left 0.5s ease;
}

.api-card:hover {
    border-color: var(--color-primary);
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.12);
    transform: translateY(-2px);
}

.api-card:hover::after {
    left: 100%;
}

.api-card textarea {
    background: var(--bg-card);
    min-height: 140px;
}

/* CodeMirror编辑器容器美化 */
.api-card .CodeMirror {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--code-bg) !important;
    font-family: 'JetBrains Mono', 'Fira Code', monospace !important;
    font-size: 14px !important;
    transition: border-color 0.2s ease;
}

.api-card .CodeMirror:focus-within {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-glow);
}

.api-card .CodeMirror-scroll {
    overflow-x: auto !important;
    overflow-y: auto !important;
}

.api-card .CodeMirror-scrollbar-filler {
    background: transparent;
}

.api-card .CodeMirror-gutters {
    background: var(--code-bg) !important;
    border-right: 1px solid var(--border-color) !important;
}

.api-card .CodeMirror-linenumber {
    color: var(--text-muted) !important;
}

.api-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 4px;
}

.api-card-header strong {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.api-card-header strong::before {
    content: '';
    width: 4px;
    height: 18px;
    background: var(--color-primary);
    border-radius: 2px;
}

.api-card-header p {
    margin: 6px 0 0;
    color: var(--text-muted);
    font-size: 0.875rem;
    line-height: 1.5;
}

.api-chip {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(59, 130, 246, 0.08));
    color: var(--color-primary);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 12px;
    border: 1px solid rgba(59, 130, 246, 0.3);
    white-space: nowrap;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.1);
    transition: all 0.2s ease;
}

.api-chip:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.2);
}

.api-chip.optional {
    background: linear-gradient(135deg, rgba(148, 163, 184, 0.15), rgba(148, 163, 184, 0.08));
    border-color: rgba(148, 163, 184, 0.3);
    color: var(--text-muted);
    box-shadow: 0 2px 4px rgba(148, 163, 184, 0.1);
}

.api-message {
    padding: 14px 18px;
    border-radius: var(--radius-md);
    font-size: 0.93rem;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.api-message::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: currentColor;
    opacity: 0.5;
}

.api-message.success {
    border-color: rgba(16, 185, 129, 0.4);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.12), rgba(16, 185, 129, 0.06));
    color: var(--color-success);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.15);
}

.api-message.error {
    border-color: rgba(239, 68, 68, 0.4);
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.12), rgba(239, 68, 68, 0.06));
    color: var(--color-danger);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.15);
}

.api-message.info {
    border-color: rgba(59, 130, 246, 0.4);
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(59, 130, 246, 0.06));
    color: var(--color-primary);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.15);
}

.api-message.muted {
    background: linear-gradient(135deg, rgba(148, 163, 184, 0.08), rgba(148, 163, 184, 0.04));
    border-color: var(--border-color);
}

.api-actions-row {
    display: flex;
    justify-content: flex-end;
    padding-top: 8px;
}

#send-request {
    min-width: 140px;
    font-size: 1rem;
    padding: 14px 28px;
    font-weight: 600;
    letter-spacing: 0.3px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#send-request::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

#send-request:hover::before {
    width: 300px;
    height: 300px;
}

#send-request:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(59, 130, 246, 0.4);
}

#send-request:active {
    transform: translateY(0);
}

.response-panel {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.03) 0%, transparent 50%);
    position: relative;
}

.response-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--color-primary), transparent);
    opacity: 0.5;
}

.api-response-meta {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.meta-card {
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-input) 100%);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.meta-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--color-primary);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.meta-card:hover {
    border-color: var(--color-primary);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
    transform: translateY(-2px);
}

.meta-card:hover::before {
    transform: scaleX(1);
}

.meta-card span {
    display: block;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.meta-card strong {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-main);
    display: block;
    background: linear-gradient(135deg, var(--text-main), var(--color-primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.response-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    margin-bottom: 8px;
    border-bottom: 2px solid var(--border-color);
}

.response-headers .response-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    margin-bottom: 8px;
    border-bottom: 2px solid var(--border-color);
}

.response-label {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 10px;
}

.response-label i {
    color: var(--color-primary);
    font-size: 1.1em;
    background: rgba(59, 130, 246, 0.1);
    padding: 6px;
    border-radius: 6px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.response-viewer {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--code-bg);
    overflow: hidden;
    transition: border-color 0.2s ease;
    position: relative;
}

.response-viewer:hover {
    border-color: var(--border-hover);
}

.response-viewer .CodeMirror {
    height: 360px;
    border: none;
    background: var(--code-bg) !important;
}

.response-viewer .CodeMirror-scroll {
    overflow-x: auto !important;
    overflow-y: auto !important;
}

.response-viewer.compact .CodeMirror {
    height: 220px;
}

.response-visual {
    display: none;
    padding: 16px;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    min-height: 180px;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.response-visual.show {
    display: flex;
}

.response-visual img {
    max-width: 100%;
    max-height: 420px;
    border-radius: var(--radius-md);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}

.response-visual .preview-meta {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Toolbox */
.toolbox-block {
    margin-top: 28px;
    padding: 22px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.toolbox-block-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
}

.toolbox-block-header h3 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toolbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 14px;
}

.toolbox-grid.dense {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.toolbox-card {
    display: flex;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-card-hover);
    color: var(--text-main);
    text-decoration: none;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.toolbox-card:hover {
    transform: translateY(-2px);
    border-color: var(--color-primary);
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.18);
}

.toolbox-card .card-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.1rem;
}

.toolbox-card .card-icon.primary { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.toolbox-card .card-icon.success { background: linear-gradient(135deg, #10b981, #0f9f79); }
.toolbox-card .card-icon.warning { background: linear-gradient(135deg, #f59e0b, #d97706); }
.toolbox-card .card-icon.info { background: linear-gradient(135deg, #06b6d4, #0891b2); }
.toolbox-card .card-icon.dark { background: linear-gradient(135deg, #475569, #1f2937); }

.toolbox-card .card-meta strong {
    display: block;
    font-size: 1rem;
    margin-bottom: 4px;
}

.toolbox-card .card-meta span {
    display: block;
    color: var(--text-muted);
    font-size: 0.92rem;
}

.toolbox-card .card-tags {
    margin-top: 8px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.toolbox-hint {
    margin-top: 14px;
    color: var(--text-muted);
    font-size: 0.92rem;
}

.toolbox-panels {
    margin-top: 18px;
}

.toolbox-panel {
    display: none;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 18px;
    background: var(--bg-card);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.toolbox-panel.active {
    display: block;
}

.panel-heading {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.panel-heading h3 {
    margin: 0;
    display: flex;
    gap: 8px;
    align-items: center;
}

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s ease;
}

.back-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.panel-body.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 14px;
}

.panel-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px;
    background: var(--bg-card-hover);
}

.panel-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.panel-card-header strong {
    font-size: 1rem;
}

.panel-card textarea {
    width: 100%;
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px;
    color: var(--text-main);
    font-family: 'JetBrains Mono', monospace;
    margin-bottom: 8px;
}

.panel-card input[type="text"],
.panel-card input[type="number"] {
    width: 100%;
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px;
    color: var(--text-main);
    margin-bottom: 8px;
}

.button-row {
    display: flex;
    gap: 10px;
    margin-bottom: 8px;
}

.flex-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.button-primary.slim-btn,
.api-ghost-btn.slim-btn {
    padding: 8px 12px;
    font-size: 0.92rem;
}

.favicon-preview {
    display: flex;
    align-items: center;
    gap: 16px;
}

#favicon-canvas {
    border: 1px dashed var(--border-color);
    background: var(--bg-body);
    border-radius: var(--radius-sm);
}

#favicon-preview-box {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.response-buttons {
    display: flex;
    gap: 8px;
}

.header-list {
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--bg-input);
    transition: all 0.3s ease;
}

.header-list:hover {
    border-color: var(--color-primary);
    border-style: solid;
    background: var(--bg-card);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
}

.header-list .header-item {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    padding: 12px;
    padding-bottom: 12px;
    min-width: 0;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    margin: 0 -4px;
}

.header-list .header-item:hover {
    background: var(--bg-card);
    border-bottom-color: var(--color-primary);
    transform: translateX(4px);
}

.header-list .header-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.header-item span {
    color: var(--text-muted);
    font-size: 0.9rem;
    flex-shrink: 0;
    white-space: nowrap;
}

.header-item code {
    font-family: 'JetBrains Mono', monospace;
    background: linear-gradient(135deg, rgba(148, 163, 184, 0.15), rgba(148, 163, 184, 0.08));
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-main);
    word-break: break-all;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    flex: 1;
    min-width: 0;
    border: 1px solid rgba(148, 163, 184, 0.2);
    transition: all 0.2s ease;
}

.header-item:hover code {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(59, 130, 246, 0.08));
    border-color: rgba(59, 130, 246, 0.3);
    color: var(--color-primary);
}

.header-list .empty {
    margin: 0;
    color: var(--text-muted);
    text-align: center;
}

.code-toggle-row {
    display: flex;
    justify-content: flex-end;
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
}

.code-expand-btn {
    background: var(--bg-input);
    border: 1px dashed var(--border-color);
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    display: none;
    transition: all 0.2s ease;
    font-weight: 500;
}

.code-expand-btn:hover {
    color: var(--color-primary);
    border-color: var(--color-primary);
    border-style: solid;
    background: var(--bg-card);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.15);
}

.CodeMirror.code-collapsed {
    position: relative;
}

.CodeMirror.code-collapsed .CodeMirror-scroll {
    max-height: 320px;
    overflow: hidden;
}

.CodeMirror.code-collapsed::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 60px;
    pointer-events: none;
    background: linear-gradient(to bottom, transparent, var(--bg-body));
}

@media (max-width: 1024px) {
    .api-debugger-heading {
        flex-direction: column;
        align-items: flex-start;
    }

    .api-request-bar {
        grid-template-columns: 1fr;
    }
}

/* Primary Action Buttons */
button[id$="btn"]:not(.expand-toggle-btn),
/* Target IDs ending in btn */
#convert-curl,
#convert-timestamp {
    background: var(--color-primary);
    color: white;
    border: 1px solid transparent;
    box-shadow: 0 4px 6px rgba(59, 130, 246, 0.25);
}

button[id$="btn"]:not(.expand-toggle-btn):hover,
#convert-curl:hover,
#convert-timestamp:hover {
    background: var(--color-primary-hover);
    box-shadow: 0 6px 12px rgba(59, 130, 246, 0.35);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* --- FANCY LOADING ANIMATIONS --- */

@keyframes btn-gradient-flow {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

@keyframes btn-pulse-glow {
    0% {
        box-shadow: 0 0 0 0 rgba(97, 218, 251, 0.7);
    }

    70% {
        box-shadow: 0 0 0 12px rgba(97, 218, 251, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(97, 218, 251, 0);
    }
}

@keyframes btn-scan-line {
    0% {
        left: -100%;
    }

    100% {
        left: 200%;
    }
}

.btn-loading-fancy {
    background: linear-gradient(270deg, var(--color-primary), #8b5cf6, #ec4899, var(--color-primary)) !important;
    background-size: 300% 300% !important;
    animation: btn-gradient-flow 2s ease infinite, btn-pulse-glow 1.5s infinite !important;
    border-color: transparent !important;
    color: white !important;
    pointer-events: none;
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.5) !important;
}

/* Scan line effect */
.btn-loading-fancy::after {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.4), transparent);
    transform: skewX(-20deg);
    animation: btn-scan-line 1s linear infinite;
}

/* --- Tool Specifics --- */

/* 1. cURL Converter */
.curl-inputs-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

#curl-converter textarea {
    min-height: 180px;
    font-size: 0.9em;
}

.language-selector {
    background: var(--bg-input);
    padding: 15px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    display: inline-flex;
    align-items: center;
    gap: 15px;
    margin: 20px 0;
}

/* Output Tabs */
.output-switcher {
    display: flex;
    gap: 4px;
    margin-bottom: -1px;
    /* Overlap border */
    position: relative;
    z-index: 5;
}

.switch-btn {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    border-radius: 0;
    padding: 12px 20px;
}

.switch-btn:hover {
    color: var(--text-main);
    background: transparent;
    transform: none;
}

.switch-btn.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

/* Code Editor Container */
.output-box {
    position: relative;
    border: 1px solid var(--border-color);
    border-radius: 0 var(--radius-sm) var(--radius-sm) var(--radius-sm);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.CodeMirror {
    height: auto !important;
    min-height: 200px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace !important;
    font-size: 14px !important;
    line-height: 1.6 !important;
    background-color: var(--code-bg) !important;
}

/* 美化CodeMirror滚动条 */
.CodeMirror-scrollbar-filler {
    background: transparent;
}

.CodeMirror-scroll::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.CodeMirror-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.CodeMirror-scroll::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.3);
    border-radius: 4px;
    transition: background 0.2s ease;
}

.CodeMirror-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.5);
}

/* 确保横向滚动条可见 */
.CodeMirror-scroll {
    overflow-x: auto !important;
    overflow-y: auto !important;
}

.cm-s-material-darker.CodeMirror {
    background-color: #0d1117 !important;
    /* Github Dark dim-ish */
}

/* Copy Button */
.copy-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 10;
    width: 36px !important;
    height: 36px !important;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-muted);
}

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

.output-extra-actions {
    display: flex;
    justify-content: flex-end;
    margin: 12px 0 8px;
}

.output-extra-actions .slim-btn {
    padding: 8px 18px;
    font-size: 0.9rem;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
}

/* Custom File Upload Button */
.button-like-label {
    background-color: var(--bg-input);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.button-like-label:hover {
    background-color: var(--bg-card-hover);
    border-color: var(--text-muted);
    color: var(--text-main);
}

/* Diff Table */
#diff-container {
    margin-top: 40px;
    background: var(--bg-input);
    border-radius: var(--radius-md);
    padding: 20px;
    border: 1px solid var(--border-color);
}

.diff-table-wrapper {
    overflow-x: auto;
}

#diff-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0;
}

#diff-table th {
    text-align: left;
    padding: 12px 16px;
    border-bottom: 2px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#diff-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    vertical-align: top;
}

#diff-table tr:last-child td {
    border-bottom: none;
}

#diff-table td:first-child {
    color: var(--color-primary);
    font-weight: 600;
}

.diff-value {
    display: block;
    padding: 10px 12px;
    background: rgba(148, 163, 184, 0.08);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-sm);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 140px;
    overflow: auto;
    line-height: 1.5;
}

.diff-value::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

.diff-value::-webkit-scrollbar-thumb {
    background: var(--color-primary);
    border-radius: 4px;
}

.diff-value::-webkit-scrollbar-track {
    background: transparent;
}

.diff-value.diff-empty {
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
}

/* 2. Timestamp Converter */
#timestamp-converter .input-group {
    display: flex;
    gap: 12px;
    background: var(--bg-input);
    padding: 8px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

#timestamp-converter input {
    border: none;
    background: transparent;
    box-shadow: none;
    font-family: 'JetBrains Mono', monospace;
}

#timestamp-converter button {
    flex-shrink: 0;
    margin: 0;
    border-radius: var(--radius-sm);
}

.result-box {
    margin-top: 20px;
    padding: 20px;
    background: var(--bg-input);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--color-primary);
    font-family: 'JetBrains Mono', monospace;
    min-height: 64px;
    display: flex;
    align-items: center;
    font-size: 1.1rem;
    color: var(--text-main);
}

/* 3. JSON Extractor */
#field-summary {
    display: inline-block;
    padding: 4px 12px;
    background: var(--bg-input);
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

#fields-config-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    background: transparent;
    border: none;
    padding: 0;
}

.field-item {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 16px;
    transition: all 0.2s;
}

.field-item:hover {
    border-color: var(--color-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.field-main {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.field-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--color-primary);
    cursor: pointer;
}

.field-item .original-name {
    font-weight: 600;
    color: var(--text-main);
    font-family: 'JetBrains Mono', monospace;
}

.field-item .rename-input {
    padding: 6px 10px;
    font-size: 0.85rem;
    border: 1px solid transparent;
    background: var(--bg-body);
}

.field-item .rename-input:focus {
    border-color: var(--color-primary);
    background: var(--bg-card);
}

.field-meta {
    padding-left: 30px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.field-item-hidden {
    display: none;
}

/* Preview Table Enhanced */
.preview-table-wrapper {
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    overflow: auto;
    position: relative;
}

#preview-table {
    width: 100%;
    border-collapse: collapse;
    /* Better for borders */
    font-size: 0.9em;
    table-layout: auto;
    /* Allow auto width but constrained by max-width cells */
}

#preview-table th {
    background: var(--bg-card);
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    text-align: left;
    padding: 12px 16px;
    position: sticky;
    top: 0;
    z-index: 2;
    box-shadow: 0 1px 0 var(--border-color);
    white-space: nowrap;
}

#preview-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    font-family: 'JetBrains Mono', monospace;
    max-width: 300px;
    /* Limit cell width */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: background-color 0.1s;
}

#preview-table tr:hover td {
    background-color: var(--bg-card-hover);
}

/* Hidden Rows Logic */
.hidden-row {
    display: none;
}

.expand-toggle-container {
    margin-top: 15px;
    text-align: center;
}

/* Expand Button */
.expand-toggle-btn {
    display: block;
    width: 100%;
    background: transparent;
    border: 1px dashed var(--border-color);
    color: var(--text-muted);
    padding: 12px;
    text-align: center;
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.expand-toggle-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: rgba(59, 130, 246, 0.05);
}

.expand-toggle-btn i {
    margin-right: 6px;
}

#ai-helper {
    display: flex;
    flex-direction: column;
    flex: 1; /* Changed from height: 100% to flex: 1 */
    min-height: 0; /* Crucial: allows flex child to shrink below content size */
    overflow: hidden; /* Crucial: contains content */
}

/* 4. AI Assistant */
.ai-panel {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.ai-history-container {
    flex: 1;
    background: transparent;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 30px;
    overflow-y: auto;
    min-height: 0;
}

.ai-thinking {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px 16px 16px 4px;
    width: fit-content;
    margin-bottom: 16px;
    animation: slideUp 0.3s ease-out;
}

.dot {
    width: 6px;
    height: 6px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) {
    animation-delay: -0.32s;
}

.dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

.ai-message {
    display: flex;
    gap: 16px;
    animation: slideUp 0.3s ease-out;
    align-self: flex-start;
    /* Default to left alignment */
}

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

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

.ai-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.ai-message.assistant {
    align-self: flex-start;
    max-width: 85%;
}

.ai-message .avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}

.ai-message.user .avatar {
    background: var(--chat-user-bg);
    color: var(--chat-user-text);
    border: none;
}

.ai-message.assistant .avatar {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--color-primary);
}

.ai-message .content {
    padding: 12px 20px;
    border-radius: 20px;
    font-size: 0.98rem;
    line-height: 1.6;
    box-shadow: var(--shadow-md);
    position: relative;
    max-width: 100%;
    word-wrap: break-word;
}

.ai-message.user .content {
    background: var(--chat-user-bg);
    color: var(--chat-user-text);
    border-radius: 20px 4px 20px 20px;
}

.ai-message.assistant .content {
    background: var(--chat-ai-bg);
    color: var(--chat-ai-text);
    border: 1px solid var(--border-color);
    border-radius: 4px 20px 20px 20px;
}


/* Styling for code blocks rendered from Markdown */
.ai-message .content pre {
    background-color: #1e2331;
    padding: 16px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(148, 163, 184, 0.25);
    box-shadow: inset 0 0 0 1px rgba(30, 41, 59, 0.55);
    overflow-x: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9em;
    margin: 12px 0;
    position: relative;
    color: #e5eaf5;
}

body.light-theme .ai-message .content pre {
    background-color: #f1f3f6;
    border-color: rgba(148, 163, 184, 0.35);
    box-shadow: inset 0 0 0 1px rgba(226, 232, 240, 0.6);
    color: #0f172a;
}

.ai-message .content pre .copy-code-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--bg-body);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    width: 32px;
    height: 32px;
    padding: 0;
    opacity: 0;
    transition: opacity 0.2s, background-color 0.2s, color 0.2s;
    cursor: pointer;
}

.ai-message .content pre:hover .copy-code-btn {
    opacity: 1;
}

.ai-message .content pre .copy-code-btn:hover {
    background: var(--color-primary);
    color: white;
    border-color: transparent;
}


.ai-message .content code {
    font-family: 'JetBrains Mono', monospace;
    background-color: var(--bg-input);
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 0.9em;
}

.ai-message .content pre code {
    background-color: transparent;
    padding: 0;
    border-radius: 0;
}

.ai-input-container {
    padding: 10px;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
}

.ai-input-wrapper {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 6px 6px 6px 10px;
    /* Reduced left padding */
    display: flex;
    align-items: flex-end;
    transition: border-color 0.2s;
    margin-top: 10px;
    margin-bottom: -18px;
}

.ai-input-wrapper:focus-within {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.ai-input-wrapper textarea {
    background: transparent;
    border: none;
    padding: 10px 0;
    max-height: 120px;
    box-shadow: none;
}

.ai-input-wrapper textarea:focus {
    box-shadow: none;
}

#ai-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    padding: 0;
    margin-left: 10px;
}

/* --- Footer --- */
footer {
    margin-top: auto;
    margin-bottom: auto;
    padding: 3px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.75rem;
    border-top: none;
}

/* Responsive Tweaks */
@media (max-width: 1024px) {
    .container {
        padding: 15px;
    }

    header {
        top: 5px;
    }
}


@media (max-width: 768px) {
    .header-content {
        padding: 0 15px;
    }

    header h1 span {
        display: none;
    }

    .header-right {
        gap: 10px;
    }

    /* Mobile Navigation */
    nav {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 280px;
        background: linear-gradient(165deg, rgba(15, 23, 42, 0.96), rgba(15, 23, 42, 0.85));
        border-left: 1px solid var(--border-color);
        flex-direction: column;
        padding: 80px 20px 20px;
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1000;
        gap: 15px;
        border-radius: 0;
        display: flex;
        box-shadow: -30px 0 60px rgba(2, 6, 23, 0.6);
        backdrop-filter: blur(18px);
        -webkit-backdrop-filter: blur(18px);
    }

    body.light-theme nav {
        background: linear-gradient(165deg, rgba(248, 250, 252, 0.98), rgba(226, 232, 240, 0.9));
        box-shadow: -30px 0 60px rgba(15, 23, 42, 0.15);
    }

    nav.is-active {
        transform: translateX(0);
    }

    .nav-link {
        font-size: 1.1rem;
        padding: 14px 16px;
        width: 100%;
        border: 1px solid transparent;
        background: rgba(148, 163, 184, 0.08);
        border-radius: var(--radius-md);
        box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
    }

    body.light-theme .nav-link {
        background: rgba(226, 232, 240, 0.75);
        box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.15);
    }

    .nav-link i {
        font-size: 1.2rem;
    }

    .nav-link:hover {
        background: rgba(59, 130, 246, 0.14);
        border-color: rgba(59, 130, 246, 0.35);
        color: var(--text-main);
    }

    .nav-link.active {
        background: rgba(59, 130, 246, 0.2);
        border-color: rgba(59, 130, 246, 0.6);
        color: var(--text-main);
        box-shadow: 0 8px 20px rgba(59, 130, 246, 0.25);
    }

    .menu-toggle {
        display: flex;
    }

    .curl-inputs-container {
        grid-template-columns: 1fr;
    }

    .tool-section {
        padding: 20px;
    }

    .ai-message {
        max-width: 95%;
    }
}

/* --- VS Code Light Theme Overrides --- */
body.light-theme .CodeMirror {
    background-color: #ffffff !important;
    color: #000000 !important;
    border-color: #e2e8f0 !important;
}

body.light-theme .CodeMirror-gutters {
    background-color: #ffffff !important;
    border-right: 1px solid #e2e8f0 !important;
}

body.light-theme .CodeMirror-linenumber {
    color: #237893 !important;
}

/* Syntax Highlighting Colors */
body.light-theme .cm-keyword {
    color: #0000ff !important;
    font-weight: bold;
}

body.light-theme .cm-operator {
    color: #000000 !important;
}

body.light-theme .cm-variable-2 {
    color: #001080 !important;
}

body.light-theme .cm-variable-3 {
    color: #001080 !important;
}

body.light-theme .cm-builtin {
    color: #0000ff !important;
}

body.light-theme .cm-atom {
    color: #0000ff !important;
}

body.light-theme .cm-number {
    color: #098658 !important;
}

body.light-theme .cm-def {
    color: #795e26 !important;
}

body.light-theme .cm-string {
    color: #a31515 !important;
}

body.light-theme .cm-string-2 {
    color: #a31515 !important;
}

body.light-theme .cm-comment {
    color: #008000 !important;
    font-style: italic;
}

body.light-theme .cm-variable {
    color: #001080 !important;
}

body.light-theme .cm-tag {
    color: #800000 !important;
}

body.light-theme .cm-attribute {
    color: #ff0000 !important;
}

body.light-theme .cm-property {
    color: #001080 !important;
}

body.light-theme .cm-meta {
    color: #800000 !important;
}

/* Selection and Cursor */
body.light-theme .CodeMirror-cursor {
    border-left: 1px solid #000000 !important;
}

body.light-theme .CodeMirror-selected {
    background: #add6ff !important;
}

body.light-theme .CodeMirror-line::selection,
body.light-theme .CodeMirror-line>span::selection,
body.light-theme .CodeMirror-line>span>span::selection {
    background: #add6ff !important;
}

/* Active Line */
body.light-theme .CodeMirror-activeline-background {
    background: #e8f2ff !important;
}

body.light-theme .CodeMirror-matchingbracket {
    color: #000000 !important;
    outline: 1px solid #bfbfbf;
    background-color: transparent !important;
}

/* Model Selector */
.model-selector {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    margin-right: 8px;
    align-self: center;
    height: fit-content;
}

.model-btn {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.model-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    transform: none;
}

.model-btn.active {
    background: var(--color-primary);
    color: white;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25);
}

.model-btn i {
    font-size: 1rem;
}

@media (max-width: 768px) {
    .model-selector {
        padding: 3px;
    }

    .model-btn {
        width: 28px;
        height: 28px;
        font-size: 0.9rem;
    }
}

.preview-header .button-primary {
    padding: 6px 14px;
    font-size: 0.875rem;
    height: auto;
}

.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    background-color: var(--bg-card);
    min-width: 160px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 100;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    padding: 5px 0;
    animation: fadeIn 0.2s ease-out;
}

.dropdown-content.show {
    display: block;
}

.dropdown-content a {
    color: var(--text-color);
    padding: 10px 15px;
    text-decoration: none;
    display: block;
    font-size: 0.9rem;
}

.dropdown-content a:hover {
    background-color: var(--bg-hover);
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: var(--bg-card);
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 450px;
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.modal-overlay.show .modal-content {
    transform: scale(1);
}

.modal-content h4 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.25rem;
}

.modal-content p {
    margin-top: 0;
    margin-bottom: 20px;
    color: var(--text-muted);
}

.modal-actions {
    margin-top: 30px;
    display: flex;
    justify-content: flex-end;
    gap: 15px;
}

.modal-actions button {
    padding: 10px 20px;
    height: auto;
}

.button-secondary {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
}
.button-secondary:hover {
    background: var(--bg-hover);
}