* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --success: #10b981;
    --text: #1f2937;
    --text-secondary: #6b7280;
    --bg: #f9fafb;
    --card-bg: #ffffff;
    --border: #e5e7eb;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 16px;
}

/* Header */
.header {
    text-align: center;
    padding: 24px 0 16px;
}

.header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Tab Container */
.tab-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.tab-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 16px 12px;
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow);
}

.tab-btn:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-lg);
}

.tab-btn.active {
    border-color: var(--primary);
    background: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.tab-icon {
    font-size: 1.5rem;
}

.tab-text {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    text-align: center;
}

.tab-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: center;
}

/* Mode Panels */
.mode-panel {
    display: none;
}

.mode-panel.active {
    display: block;
}

/* Input Section */
.input-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}

.input-label {
    display: block;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text);
}

.input-textarea {
    width: 100%;
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 1rem;
    line-height: 1.5;
    resize: vertical;
    transition: border-color 0.2s;
    font-family: inherit;
}

.input-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.input-textarea::placeholder {
    color: #9ca3af;
}

.spec-textarea {
    min-height: 150px;
}

/* Polish Bar */
.polish-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
}

.polish-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.polish-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.polish-btn:active {
    transform: translateY(0);
}

.polish-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.polish-btn.loading .polish-icon {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.polish-icon {
    font-size: 1rem;
    display: inline-block;
}

.polish-status {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.polish-status.success {
    color: var(--success);
    font-weight: 500;
}

.polish-status.error {
    color: #ef4444;
    font-weight: 500;
}

/* AI Question Section */
.ai-question {
    margin-bottom: 0;
}

.question-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 14px;
    color: var(--text);
}

.radio-group {
    display: flex;
    gap: 12px;
}

.radio-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--primary-light);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
    flex: 1;
    justify-content: center;
}

.radio-item:has(input:checked) {
    border-color: var(--primary);
    background: #e0e7ff;
}

.radio-item input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

.radio-label {
    font-size: 0.95rem;
    font-weight: 500;
    user-select: none;
}

/* AI Section */
.ai-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
    animation: slideDown 0.3s ease;
}

.ai-section.hidden {
    display: none;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.section-hint {
    font-weight: 400;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.ai-checkboxes {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--primary-light);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.checkbox-item:has(input:checked) {
    border-color: var(--primary);
    background: #e0e7ff;
}

.ai-checkbox {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

.checkbox-label {
    font-size: 0.9rem;
    font-weight: 500;
    user-select: none;
}

/* Generate Button */
.generate-btn {
    display: block;
    width: 100%;
    padding: 16px 24px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.generate-btn:hover {
    background: var(--primary-hover);
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

.generate-btn:active {
    transform: translateY(0);
}

/* Output Section */
.output-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.output-section.hidden {
    display: none;
}

.output-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: var(--primary-light);
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 0.95rem;
    font-weight: 600;
}

.copy-btn {
    padding: 6px 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.copy-btn:hover {
    background: var(--primary-hover);
}

.copy-btn.copied {
    background: var(--success);
}

.card-body {
    padding: 16px 20px;
    max-height: 300px;
    overflow-y: auto;
}

.output-text {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 0.85rem;
    line-height: 1.7;
    color: var(--text);
    font-family: inherit;
}

/* Usage Tip */
.usage-tip {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: var(--radius);
    padding: 14px 18px;
    font-size: 0.85rem;
    color: #166534;
    line-height: 1.6;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    transition: opacity 0.3s, transform 0.3s;
}

.toast.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(10px);
    pointer-events: none;
}

/* Footer */
.footer {
    text-align: center;
    padding: 24px 0;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* 抖动动画 */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-4px); }
    40% { transform: translateX(4px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

.shake {
    animation: shake 0.4s ease;
    border-color: #ef4444 !important;
}

/* ========== 响应式设计 ========== */

/* 小屏手机 (<=375px) */
@media (max-width: 375px) {
    .container {
        padding: 12px;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .tab-container {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .tab-btn {
        padding: 12px;
    }

    .radio-group {
        flex-direction: column;
    }

    .ai-checkboxes {
        grid-template-columns: 1fr;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .copy-btn {
        width: 100%;
        text-align: center;
    }
}

/* 中等手机 (376px - 480px) */
@media (min-width: 376px) and (max-width: 480px) {
    .ai-checkboxes {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* 平板 (481px - 768px) */
@media (min-width: 481px) and (max-width: 768px) {
    .container {
        padding: 20px;
    }

    .ai-checkboxes {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* 桌面端 (769px+) */
@media (min-width: 769px) {
    .container {
        padding: 32px;
    }

    .header {
        padding: 40px 0 24px;
    }

    .header h1 {
        font-size: 2rem;
    }

    .ai-checkboxes {
        grid-template-columns: repeat(3, 1fr);
    }

    .card-body {
        max-height: 400px;
    }
}
