/* 亮色主题（默认） */
:root {
    --background: #ffffff;
    --foreground: #020817;
    --muted: #f1f5f9;
    --muted-foreground: #64748b;
    --border: #e2e8f0;
    --input: #e2e8f0;
    --primary: #18181b;
    --primary-foreground: #ffffff;
    --ring: #18181b;
    --radius: 0.5rem;
    --navbar-bg: #ffffff;
    --navbar-border: #e2e8f0;
}

/* 暗色主题 */
[data-theme="dark"] {
    --background: #020817;
    --foreground: #ffffff;
    --muted: #1e293b;
    --muted-foreground: #94a3b8;
    --border: #1e293b;
    --input: #1e293b;
    --primary: #ffffff;
    --primary-foreground: #020817;
    --ring: #cbd5e1;
    --navbar-bg: #0f172a;
    --navbar-border: #1e293b;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--background);
    color: var(--foreground);
    line-height: 1.5;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.navbar {
    background-color: var(--navbar-bg);
    border-bottom: 1px solid var(--navbar-border);
    padding: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.navbar-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--foreground);
    text-decoration: none;
    letter-spacing: -0.025em;
}

.navbar-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.theme-switch, .lang-switch {
    padding: 0.5rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--foreground);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.theme-switch:hover, .lang-switch:hover {
    background-color: var(--muted);
}

.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

.container {
    display: grid;
    grid-template-columns: minmax(400px, 1fr) minmax(400px, 1fr);
    gap: 1.5rem;
    margin-top: 1.5rem;
}

textarea {
    width: 100%;
    height: 300px;
    padding: 0.75rem;
    background-color: var(--background);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    color: var(--foreground);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    resize: vertical;
    transition: all 0.2s ease;
}

/* 修改聚焦时的样式 */
textarea:focus {
    outline: none;
    border-color: var(--primary);
    border-width: 2px;
    box-shadow: none;
}

.output {
    height: 400px;
    padding: 0.75rem;
    background-color: var(--muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--foreground);
    font-size: 0.875rem;
    line-height: 1.5;
    overflow-y: auto;
    white-space: pre-wrap;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.header {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    text-align: left;
}

.header h1 {
    font-size: 2rem;
    line-height: 1.2;
}

.subtitle {
    font-size: 1rem;
    color: var(--muted-foreground);
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
    align-items: center;
}

.mode-switch {
    flex: 1;
    min-width: 200px;
}

.citation-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
    color: var(--muted-foreground);
    font-size: 0.875rem;
}

.citation-control input[type="checkbox"] {
    width: 14px;
    height: 14px;
    margin: 0;
    vertical-align: middle;
    position: relative;
    top: -1px;
}

select {
    padding: 0.5rem 2.5rem 0.5rem 0.75rem;
    background-color: var(--background);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--foreground);
    font-size: 0.875rem;
    line-height: 1.25rem;
    appearance: none;
}

select:focus {
    outline: none;
    border-color: var(--ring);
    box-shadow: 0 0 0 2px var(--background), 0 0 0 4px var(--ring);
}

button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    background-color: var(--primary);
    color: var(--primary-foreground);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25rem;
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s ease;
}

button:hover {
    opacity: 0.9;
}

button:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--background), 0 0 0 4px var(--ring);
}

.buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1rem;
}

.input-label, .output-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.input-label button, .output-label button {
    background-color: transparent;
    border-color: transparent;
    color: var(--muted-foreground);
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.input-label button:hover, .output-label button:hover {
    background-color: var(--muted);
}

@media (max-width: 900px) {
    .container {
        grid-template-columns: 1fr;
    }
    
    textarea, .output {
        min-width: 100%;
    }

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

.preview-area {
    margin-top: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: none; /* 默认隐藏 */
}

.preview-area.active {
    display: block;
}

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

.preview-header h3 {
    margin: 0;
    font-size: 0.9rem;
    color: var(--muted-foreground);
}

.preview-toggle {
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
}

.preview-content {
    padding: 1rem;
    max-height: 200px;
    overflow-y: auto;
    background: var(--background);
}

/* 预览区域的内容样式 */
.preview-content h1,
.preview-content h2,
.preview-content h3,
.preview-content h4,
.preview-content h5,
.preview-content h6 {
    margin-top: 0.5em;
    margin-bottom: 0.5em;
}

.preview-content p {
    margin: 0.5em 0;
}

.preview-content code {
    background: var(--muted);
    padding: 0.2em 0.4em;
    border-radius: 3px;
}

.preview-content pre {
    background: var(--muted);
    padding: 1em;
    border-radius: var(--radius);
    overflow-x: auto;
}

.tab-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 0.5rem 0;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--muted-foreground);
    padding: 0.5rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    position: relative;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    color: var(--foreground);
}

.tab-btn.active {
    color: var(--foreground);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--foreground);
    border-radius: 2px;
}

#output-wrapper {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    height: 400px;
    position: relative;
    margin-top: 0;
}

#output-wrapper .output {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    height: 300px;
    padding: 1rem;
    display: none;
    overflow-y: auto;
    background: var(--background);
}

#output-wrapper .output.active {
    display: block;
}

/* 预览模式下的样式 */
#preview-area {
    white-space: normal;
    height: 300px;
    padding: 1rem;
    line-height: 1.6;
}

#preview-area h1,
#preview-area h2,
#preview-area h3,
#preview-area h4,
#preview-area h5,
#preview-area h6 {
    margin: 1em 0 0.5em;
}

#preview-area p {
    margin: 0.5em 0;
}

#preview-area code {
    background: var(--muted);
    padding: 0.2em 0.4em;
    border-radius: 3px;
}

#preview-area pre {
    background: var(--muted);
    padding: 1em;
    border-radius: var(--radius);
    overflow-x: auto;
}

.output-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.preview-btn {
    background: transparent;
    border: none;
    color: var(--muted-foreground);
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s ease;
}

.preview-btn:hover {
    color: var(--foreground);
}

.preview-btn.active {
    color: var(--foreground);
    background: transparent;
    border: none;
    font-weight: 500;
}

#output-wrapper {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    height: 400px;
    position: relative;
}

#output-wrapper .output {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    height: 300px;
    padding: 1rem;
    display: none;
    overflow-y: auto;
    background: var(--background);
}

#output-wrapper .output.active {
    display: block;
}

.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: var(--primary-foreground);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
}

/* 让输出区域看起来可点击 */
#output-wrapper .output {
    cursor: pointer;
}

#output-wrapper .output:hover {
    background: var(--muted);
}

.perplexity-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    padding: 0.1em 0.3em;
    border-radius: var(--radius);
    transition: all 0.2s ease;
}

.perplexity-link:hover {
    background: var(--muted);
    text-decoration: underline;
}

[data-theme="dark"] .perplexity-link {
    color: #94a3b8;
}

[data-theme="dark"] .perplexity-link:hover {
    color: var(--foreground);
}

/* 调整 header 部分的响应式布局 */
.header {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    text-align: left;
}

.header h1 {
    font-size: 2rem;
    line-height: 1.2;
}

.subtitle {
    font-size: 1rem;
    color: var(--muted-foreground);
}

/* 调整控制区域的响应式布局 */
.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
    align-items: center;
}

.mode-switch {
    flex: 1;
    min-width: 200px;
}

.citation-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
    color: var(--muted-foreground);
    font-size: 0.875rem;
}

.citation-control input[type="checkbox"] {
    width: 14px;
    height: 14px;
    margin: 0;
    vertical-align: middle;
    position: relative;
    top: -1px;
}

/* 移动端适配 */
@media (max-width: 640px) {
    .citation-control {
        margin-left: 0;
        width: 100%;
    }
}

/* 修改导航栏的响应式布局 */
@media (max-width: 640px) {
    .navbar {
        padding: 0.75rem;  /* 减小内边距 */
    }

    .navbar-container {
        flex-direction: row;  /* 改回横向排列 */
        justify-content: space-between;  /* 两端对齐 */
        align-items: center;
        padding: 0;
        gap: 0.5rem;  /* 减小间距 */
    }

    .logo {
        font-size: 1.25rem;  /* 稍微减小 logo 字体小 */
    }

    .navbar-controls {
        gap: 0.5rem;  /* 减小控制按钮之间的间距 */
    }

    .theme-switch, .lang-switch {
        padding: 0.35rem;  /* 减小按钮内边距 */
        font-size: 0.875rem;  /* 减小按钮文字大小 */
    }
}

/* 调整中等屏幕的布局 */
@media (min-width: 641px) and (max-width: 1024px) {
    .container {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .header h1 {
        font-size: 1.75rem;
    }

    .main-content {
        padding: 1.25rem;
    }
}

/* 优化按钮在移动端的显示 */
.buttons button {
    width: 100%;
    padding: 0.5rem;
    white-space: nowrap;
}

/* 优化链接在移动端的显示 */
.perplexity-link {
    display: inline-block;
    margin: 0.2em 0;
}

/* 优化 Toast 在移动端的显示 */
@media (max-width: 640px) {
    .toast {
        width: calc(100% - 2rem);
        margin: 0 1rem;
        text-align: center;
    }
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

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

.logo-image {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

/* 在移动端适配中 */
@media (max-width: 640px) {
    .brand {
        gap: 0.5rem;
    }
    
    .logo-image {
        width: 24px;
        height: 24px;
    }
}

/* Footer 样式 */
.footer {
    background-color: var(--background-secondary);
    padding: 3rem 1rem 1rem;
    margin-top: 4rem;
    border-top: 1px solid var(--border-color);
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    padding: 0 1rem;
}

.footer-section h3 {
    color: var(--text-primary);
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.footer-section p {
    color: var(--text-secondary);
    line-height: 1.6;
}

.footer-section ul {
    list-style: none;
    padding: 0;
}

.footer-section ul li {
    margin-bottom: 0.5rem;
}

.footer-section a {
    color: var(--primary);
    text-decoration: none;
    font-weight: normal;
    padding: 0.1em 0.3em;
    border-radius: var(--radius);
    transition: all 0.2s ease;
}

.footer-section a:hover {
    background: var(--muted);
    text-decoration: underline;
}

[data-theme="dark"] .footer-section a {
    color: #94a3b8;
}

[data-theme="dark"] .footer-section a:hover {
    color: var(--foreground);
}

.social-links {
    display: flex;
    gap: 1rem;
}

.social-icon {
    color: var(--primary);
    transition: color 0.2s, transform 0.2s;
    width: 24px;
    height: 24px;
}

.social-icon:hover {
    color: var(--primary);
    opacity: 0.8;
    transform: scale(1.1);
}

[data-theme="dark"] .social-icon {
    color: #94a3b8;
}

[data-theme="dark"] .social-icon:hover {
    color: var(--foreground);
}

.footer-bottom {
    max-width: 1200px;
    margin: 2rem auto 0;
    padding: 1rem;
    text-align: center;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .footer-content {
        grid-template-columns: 1fr;
        text-align: center;
    }
    
    .social-links {
        justify-content: center;
    }
}

/* 政策页面样式 */
.policy-content {
    max-width: 800px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

.policy-section {
    margin: 2rem 0;
}

.policy-section h2 {
    color: var(--foreground);
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.policy-section p {
    color: var(--muted-foreground);
    line-height: 1.6;
    margin-bottom: 1rem;
}

/* 响应式调整 */
@media (max-width: 640px) {
    .policy-content {
        margin: 1rem auto;
        padding: 0 1rem;
    }

    .policy-section {
        margin: 1.5rem 0;
    }

    .policy-section h2 {
        font-size: 1.25rem;
    }
}

/* 列表样式 */
ul, ol {
    padding-left: 2em;
    margin: 1em 0;
}

/* 嵌套列表的样式 */
ul ul, 
ul ol,
ol ul,
ol ol {
    margin: 0.5em 0;
    padding-left: 2em;
}

/* 列表项样式 */
li {
    margin: 0.5em 0;
}

/* 引用块样式 */
blockquote {
    margin: 1.5em 0;
    padding: 1em 1.5em;
    border-left: 4px solid #ddd;
    background-color: #f8f9fa;
    color: #555;
}

/* 深色模式下的引用块样式 */
[data-theme="dark"] blockquote {
    background-color: #1a1a1a;
    border-left-color: #444;
    color: #bbb;
}

/* 预览区域样式 */
#preview-area {
    padding: 2em;
    line-height: 1.6;
}

/* 确保预览区域内的列表和引用块样式正确显示 */
#preview-area ul,
#preview-area ol {
    padding-left: 2em;
    margin: 1em 0;
}

#preview-area blockquote {
    margin: 1.5em 0;
    padding: 1em 1.5em;
}

/* 左右两个主容器的样式 */
.container > div {
    display: flex;
    flex-direction: column;
    min-height: 400px;
}

/* 文本区域和输出区域的样式 */
textarea, #output-wrapper {
    flex: 1;  /* 让文本区域和输出区域占据剩余空间 */
    height: 300px; /* 统一设置为 300px */
    margin-bottom: 1rem;
}

/* 输入区域按钮组 */
.input-buttons {
    display: flex;
    gap: 0.5rem;
    margin-top: auto; /* 将按钮组推到底部 */
}

/* 输出区域按钮组 */
.output-buttons {
    display: flex;
    gap: 0.5rem;
    margin-top: auto; /* 将按钮组推到底部 */
}

/* 确保按钮样式一致 */
.input-buttons button,
.output-buttons button {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
}

/* 移动端适配 */
@media (max-width: 640px) {
    .input-buttons,
    .output-buttons {
        flex-direction: column;
    }
}