/* =============================================
   问题解答 - problem_solving.css
   紫色·智慧光芒主题，三栏布局
   dark mode: body.dark 前缀
   ============================================= */

/* ========== 主容器 ========== */
.ps-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
    min-height: 600px;
    background: #f5f0ff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(124, 58, 237, 0.12);
    transition: all 0.3s ease;
}

/* 全屏模式 */
.ps-container.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9999;
    border-radius: 0;
    margin: 0;
    min-height: unset;
}

/* ========== 顶部工具栏 ========== */
.ps-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    background: linear-gradient(135deg, #4c1d95 0%, #7c3aed 55%, #a855f7 100%);
    color: white;
    flex-wrap: wrap;
    gap: 8px;
    box-shadow: 0 2px 16px rgba(124, 58, 237, 0.5);
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.ps-toolbar .toolbar-title {
    font-size: 13px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.95);
    letter-spacing: 0.5px;
    margin-right: 8px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.toolbar-group {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
    min-height: 28px;
}

.toolbar-group--right {
    margin-left: auto;
}

.toolbar-btn {
    padding: 5px 11px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: #ffffff;
    transition: all 0.2s;
    white-space: nowrap;
    backdrop-filter: blur(4px);
}

.toolbar-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.28);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
}

.toolbar-btn:active:not(:disabled) {
    transform: translateY(0);
}

.toolbar-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* 主操作按钮（开始解答） */
.toolbar-btn-primary {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
    border-color: transparent !important;
    font-weight: 700;
    font-size: 13px;
    box-shadow: 0 2px 12px rgba(245, 158, 11, 0.55);
    color: #fff !important;
    letter-spacing: 0.3px;
}

.toolbar-btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%) !important;
    box-shadow: 0 4px 18px rgba(245, 158, 11, 0.65);
    color: #fff !important;
    transform: translateY(-1px);
}

/* ========== 表单校验抖动 ========== */
@keyframes ps-shake {
    0%, 100% { transform: translateX(0); }
    10%, 50%, 90% { transform: translateX(-5px); }
    30%, 70% { transform: translateX(5px); }
}

.ps-input.shake,
.ps-select.shake,
.ps-textarea.shake {
    animation: ps-shake 0.5s ease-in-out;
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12) !important;
}

/* ========== 主内容区：三栏 ========== */
.ps-main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    background: #f5f0ff;
}

/* ========== 左栏：历史记录 ========== */
.ps-history-panel {
    width: 210px;
    flex-shrink: 0;
    background: #ffffff;
    border-right: 1px solid #ede9fe;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.history-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    background: linear-gradient(to bottom, #f5f0ff 0%, #ede9fe 100%);
    border-bottom: 1px solid #ddd6fe;
    flex-shrink: 0;
}

.history-panel-header h3 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: #4c1d95;
}

.history-count {
    font-size: 11px;
    color: #7c3aed;
    font-weight: 400;
}

.history-limit-footer {
    flex-shrink: 0;
    padding: 5px 8px;
    text-align: center;
    font-size: 10px;
    color: #a78bfa;
    border-top: 1px solid #ede9fe;
    background: #f5f0ff;
    letter-spacing: 0.2px;
    user-select: none;
}

.history-clear-btn {
    background: #fff0f0;
    border: none;
    color: #ef4444;
    font-size: 11px;
    cursor: pointer;
    padding: 2px 7px;
    border-radius: 3px;
    transition: background 0.2s;
    white-space: nowrap;
}

.history-clear-btn:hover {
    background: #fde8e8;
}

.history-search {
    padding: 8px;
    border-bottom: 1px solid #ede9fe;
    flex-shrink: 0;
}

.history-search input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #c4b5fd;
    border-radius: 4px;
    font-size: 12px;
    outline: none;
    transition: all 0.2s;
    box-sizing: border-box;
    color: #4c1d95;
    background: #faf8ff;
}

.history-search input:focus {
    border-color: #7c3aed;
    box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.1);
}

.history-search input::placeholder {
    color: #c4b5fd;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
    background: #ffffff;
}

.history-list::-webkit-scrollbar {
    width: 4px;
}

.history-list::-webkit-scrollbar-track {
    background: transparent;
}

.history-list::-webkit-scrollbar-thumb {
    background: #c4b5fd;
    border-radius: 2px;
}

.history-list::-webkit-scrollbar-thumb:hover {
    background: #a78bfa;
}

.history-empty {
    text-align: center;
    color: #c4b5fd;
    font-size: 12px;
    padding: 24px 8px;
    user-select: none;
}

/* 历史记录条目 */
.history-item {
    display: flex;
    flex-direction: column;
    padding: 9px 11px;
    margin: 3px 0;
    background: #faf8ff;
    border: 1px solid #ede9fe;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.18s;
    position: relative;
    animation: ps-fadeIn 0.2s ease;
}

@keyframes ps-fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.history-item:hover {
    background: #f5f0ff;
    border-color: #a78bfa;
    transform: translateX(2px);
}

.history-item.active {
    background: #ede9fe;
    border-color: #7c3aed;
    box-shadow: 0 1px 4px rgba(124, 58, 237, 0.2), inset 3px 0 0 #7c3aed;
}

.history-item-delete {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 18px;
    height: 18px;
    background: #fde8e8;
    color: #ef4444;
    border: none;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    opacity: 0;
    transition: all 0.18s;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.history-item:hover .history-item-delete {
    opacity: 1;
}

.history-item-delete:hover {
    background: #ef4444;
    color: white;
}

.history-item-title {
    font-size: 12px;
    font-weight: 600;
    color: #4c1d95;
    margin-bottom: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 20px;
}

.history-item-category {
    display: inline-block;
    font-size: 10px;
    color: #fff;
    background: linear-gradient(135deg, #7c3aed, #a855f7);
    padding: 1px 6px;
    border-radius: 8px;
    margin-bottom: 3px;
    font-weight: 500;
}

.history-item-time {
    font-size: 10px;
    color: #c4b5fd;
}

/* ========== 中栏：输入面板 ========== */
.ps-input-panel {
    width: 360px;
    flex-shrink: 0;
    background: #ffffff;
    border-right: 1px solid #ede9fe;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 11px 16px;
    background: linear-gradient(to bottom, #f5f0ff 0%, #ede9fe 100%);
    border-bottom: 1px solid #ddd6fe;
    flex-shrink: 0;
    min-height: 44px;
}

.panel-header h3 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: #4c1d95;
    border-left: 4px solid #2ECC71;
    padding-left: 10px;
}

.panel-tip {
    font-size: 11px;
    color: #a78bfa;
    background: rgba(237, 233, 254, 0.5);
    padding: 2px 8px;
    border-radius: 4px;
}

.ps-input-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.ps-input-body::-webkit-scrollbar {
    width: 4px;
}

.ps-input-body::-webkit-scrollbar-thumb {
    background: #c4b5fd;
    border-radius: 2px;
}

.ps-input-body::-webkit-scrollbar-thumb:hover {
    background: #a78bfa;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group-row {
    flex-direction: row;
    gap: 10px;
}

.form-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 12px;
    font-weight: 600;
    color: #5b21b6;
}

.required-mark {
    color: #ef4444;
    margin-left: 2px;
}

.label-tip {
    font-size: 10px;
    font-weight: 400;
    color: #a78bfa;
}

.ps-select,
.ps-input {
    padding: 8px 10px;
    border: 1px solid #c4b5fd;
    border-radius: 5px;
    font-size: 13px;
    color: #4c1d95;
    background: #faf8ff;
    outline: none;
    transition: all 0.2s;
    width: 100%;
    box-sizing: border-box;
}

.ps-select:focus,
.ps-input:focus {
    border-color: #7c3aed;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.ps-textarea {
    padding: 10px 12px;
    border: 1px solid #c4b5fd;
    border-radius: 5px;
    font-size: 13px;
    color: #4c1d95;
    background: #faf8ff;
    outline: none;
    resize: vertical;
    min-height: 120px;
    font-family: inherit;
    line-height: 1.7;
    transition: all 0.2s;
    width: 100%;
    box-sizing: border-box;
}

.ps-textarea:focus {
    border-color: #7c3aed;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.ps-textarea::placeholder {
    color: #c4b5fd;
    font-family: inherit;
}

.ps-textarea-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2px;
}

.ps-textarea-hint {
    font-size: 10px;
    color: #a78bfa;
}

#charCount {
    font-size: 10px;
    color: #a78bfa;
}

#charCount.warn {
    color: #f59e0b;
    font-weight: 600;
}

#charCount.danger {
    color: #ef4444;
    font-weight: 700;
}

/* ========== 右栏：结果面板 ========== */
.ps-result-panel {
    flex: 1;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 300px;
}

.result-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-left: auto;
}

.result-category-tag {
    font-size: 11px;
    color: #fff;
    background: linear-gradient(135deg, #7c3aed, #a855f7);
    padding: 3px 10px;
    border-radius: 10px;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(124, 58, 237, 0.3);
}

.result-word-count {
    font-size: 11px;
    color: #64748b;
    background: #f1f5f9;
    padding: 3px 8px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}

.result-time {
    font-size: 11px;
    color: #94a3b8;
    font-weight: 500;
    padding: 2px 6px;
    background: rgba(148, 163, 184, 0.1);
    border-radius: 4px;
}

.result-regen-btn {
    font-size: 11px;
    color: #7c3aed;
    background: #f5f0ff;
    border: 1px solid #c4b5fd;
    padding: 3px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    font-weight: 500;
}

.result-regen-btn:hover {
    background: #ede9fe;
    border-color: #7c3aed;
}

.ps-result-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    position: relative;
    background: #ffffff;
}

.ps-result-body::-webkit-scrollbar {
    width: 6px;
}

.ps-result-body::-webkit-scrollbar-track {
    background: #f5f0ff;
}

.ps-result-body::-webkit-scrollbar-thumb {
    background: #c4b5fd;
    border-radius: 3px;
}

.ps-result-body::-webkit-scrollbar-thumb:hover {
    background: #a78bfa;
}

/* 占位区 */
.result-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 200px;
    padding: 40px 20px;
    text-align: center;
    color: #c4b5fd;
    user-select: none;
}

.placeholder-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.8;
    animation: ps-float 3s ease-in-out infinite;
}

@keyframes ps-float {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(-8px); }
}

.placeholder-title {
    font-size: 16px;
    font-weight: 600;
    color: #8b5cf6;
    margin: 0 0 8px 0;
}

.placeholder-desc {
    font-size: 13px;
    color: #a78bfa;
    margin: 2px 0;
}

.placeholder-quote {
    margin-top: 20px;
    padding: 10px 20px;
    border-left: 3px solid #7c3aed;
    font-size: 12px;
    font-style: italic;
    color: #8b5cf6;
    background: #f5f0ff;
    border-radius: 0 6px 6px 0;
}

/* 加载中 */
.result-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 200px;
    padding: 40px;
    position: relative;
    overflow: hidden;
}

/* 进度光条动画 */
.ps-loading-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, transparent 0%, #a855f7 40%, #f59e0b 60%, transparent 100%);
    background-size: 200% 100%;
    animation: ps-loadingBar 1.6s ease-in-out infinite;
}

@keyframes ps-loadingBar {
    0%   { background-position: -100% 0; }
    100% { background-position: 200% 0; }
}

.loading-dots {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.loading-dots span {
    width: 12px;
    height: 12px;
    background: #7c3aed;
    border-radius: 50%;
    animation: ps-bounce 1.2s ease-in-out infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes ps-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
    40%            { transform: translateY(-16px); opacity: 1; }
}

.loading-text {
    font-size: 14px;
    color: #8b5cf6;
    font-weight: 500;
    margin: 0;
}

/* 结果内容区 */
.result-content {
    font-size: 14px;
    line-height: 1.8;
    color: #3b0764;
}

/* Markdown 渲染样式 */
.result-content h3 {
    font-size: 15px;
    font-weight: 700;
    color: #5b21b6;
    margin: 18px 0 8px 0;
    padding: 6px 0 6px 10px;
    border-left: 3px solid #7c3aed;
    background: linear-gradient(to right, #f5f0ff, transparent);
    border-radius: 0 4px 4px 0;
}

.result-content h4 {
    font-size: 13px;
    font-weight: 700;
    color: #6d28d9;
    margin: 12px 0 6px 0;
}

.result-content p {
    margin: 0 0 10px 0;
    color: #374151;
}

.result-content ul,
.result-content ol {
    margin: 6px 0 10px 0;
    padding-left: 22px;
}

.result-content li {
    margin-bottom: 5px;
    color: #374151;
}

.result-content li::marker {
    color: #ff9800;
    font-weight: 600;
}

.result-content code {
    font-family: 'Consolas', 'Menlo', 'Monaco', monospace;
    font-size: 12.5px;
    background: #f5f0ff;
    color: #5b21b6;
    padding: 1px 5px;
    border-radius: 3px;
    border: 1px solid #ddd6fe;
}

.result-content pre {
    background: #1e0a2e;
    color: #e9d5ff;
    padding: 14px 16px;
    border-radius: 7px;
    overflow-x: auto;
    margin: 10px 0;
    font-size: 12.5px;
    line-height: 1.75;
    box-shadow: 0 4px 12px rgba(76, 29, 149, 0.25);
    border: 1px solid #2d1b4e;
}

.result-content pre code {
    background: transparent;
    color: #e9d5ff;
    padding: 0;
    border: none;
    font-size: inherit;
}

.result-content strong {
    color: #5b21b6;
    font-weight: 700;
}

.result-content em {
    color: #7c3aed;
    font-style: italic;
}

.result-content hr {
    border: none;
    border-top: 1px solid #ede9fe;
    margin: 14px 0;
}

.result-content blockquote {
    border-left: 3px solid #7c3aed;
    background: #f5f0ff;
    padding: 8px 14px;
    margin: 10px 0;
    border-radius: 0 5px 5px 0;
    color: #374151;
}

/* 结果区入场动画 */
@keyframes ps-resultFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ps-result-enter {
    animation: ps-resultFadeIn 0.35s ease-out forwards;
}

/* 错误提示框 */
.ps-error-box {
    color: #ef4444;
    padding: 16px 18px;
    background: #fef2f2;
    border-radius: 6px;
    border-left: 3px solid #ef4444;
    line-height: 1.6;
}

.result-content--error {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    flex: 1;
}

.ps-error-box strong {
    color: #dc2626;
    font-size: 14px;
    display: block;
    margin-bottom: 6px;
}

.ps-error-retry-btn {
    display: inline-block;
    margin-top: 12px;
    padding: 6px 14px;
    background: #fee2e2;
    border: 1px solid #fca5a5;
    border-radius: 5px;
    color: #dc2626;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.ps-error-retry-btn:hover {
    background: #fecaca;
    border-color: #f87171;
}

/* ========== 示例模态框 ========== */
.ps-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 99998;
    backdrop-filter: blur(2px);
    animation: ps-overlayFadeIn 0.2s ease;
}

@keyframes ps-overlayFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.ps-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 99999;
    width: 680px;
    max-width: 95vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.ps-modal-content {
    background: #ffffff;
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 80vh;
    box-shadow: 0 16px 48px rgba(76, 29, 149, 0.2);
    animation: ps-modalIn 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes ps-modalIn {
    from { opacity: 0; transform: scale(0.92); }
    to   { opacity: 1; transform: scale(1); }
}

.ps-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    background: linear-gradient(135deg, #4c1d95 0%, #7c3aed 100%);
    color: white;
    flex-shrink: 0;
}

.ps-modal-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}

.ps-modal-close {
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 14px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.ps-modal-close:hover {
    background: rgba(255, 255, 255, 0.35);
}

.ps-modal-body {
    overflow-y: auto;
    padding: 16px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    background: #faf8ff;
}

.ps-modal-body::-webkit-scrollbar {
    width: 6px;
}

.ps-modal-body::-webkit-scrollbar-thumb {
    background: #c4b5fd;
    border-radius: 3px;
}

/* 示例卡片 */
.example-card {
    background: #ffffff;
    border: 1px solid #ede9fe;
    border-radius: 8px;
    padding: 12px 14px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    gap: 5px;
    position: relative;
}

.example-card:hover {
    border-color: #7c3aed;
    background: #f5f0ff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.15);
}

.example-card-top {
    display: flex;
    align-items: center;
    gap: 8px;
}

.example-card-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.example-card-title {
    font-size: 13px;
    font-weight: 600;
    color: #4c1d95;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.example-card-badge {
    font-size: 10px;
    color: #fff;
    background: linear-gradient(135deg, #7c3aed, #a855f7);
    padding: 1px 7px;
    border-radius: 8px;
    font-weight: 500;
    white-space: nowrap;
}

.example-card-desc {
    font-size: 12px;
    color: #6b7280;
    line-height: 1.5;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* ========== 暗黑模式 ========== */
body.dark .ps-container {
    background: #1a0533;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}

body.dark .ps-toolbar {
    background: linear-gradient(135deg, #2d1b69 0%, #4c1d95 55%, #6d28d9 100%);
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.4);
    border-bottom-color: rgba(255, 255, 255, 0.07);
}

body.dark .ps-main-content {
    background: #1a0533;
}

body.dark .ps-history-panel {
    background: #1e0a2e;
    border-right-color: #2d1b4e;
}

body.dark .history-panel-header {
    background: linear-gradient(to bottom, #2d1b4e 0%, #22103a 100%);
    border-bottom-color: #3d2264;
}

body.dark .history-panel-header h3 {
    color: #d8b4fe;
}

body.dark .history-limit-footer {
    background: #1e0a2e;
    border-top-color: #2d1b4e;
    color: #6d28d9;
}

body.dark .history-search {
    border-bottom-color: #2d1b4e;
}

body.dark .history-search input {
    border-color: #3d2264;
    background: #2d1b4e;
    color: #e9d5ff;
}

body.dark .history-search input:focus {
    border-color: #7c3aed;
}

body.dark .history-search input::placeholder {
    color: #5b21b6;
}

body.dark .history-list {
    background: #1e0a2e;
}

body.dark .history-empty {
    color: #5b21b6;
}

body.dark .history-item {
    background: #2d1b4e;
    border-color: #3d2264;
}

body.dark .history-item:hover {
    background: #3b1f6b;
    border-color: #7c3aed;
}

body.dark .history-item.active {
    background: #3d2264;
    border-color: #a855f7;
    box-shadow: 0 1px 4px rgba(124, 58, 237, 0.3), inset 3px 0 0 #a855f7;
}

body.dark .history-item-title {
    color: #e9d5ff;
}

body.dark .history-item-time {
    color: #6d28d9;
}

body.dark .ps-input-panel {
    background: #1e0a2e;
    border-right-color: #2d1b4e;
}

body.dark .panel-header {
    background: linear-gradient(to bottom, #2d1b4e 0%, #22103a 100%);
    border-bottom-color: #3d2264;
}

body.dark .panel-header h3 {
    color: #d8b4fe;
    border-left-color: #27ae60;
}

body.dark .panel-tip {
    color: #7c3aed;
    background: rgba(45, 27, 78, 0.5);
}

body.dark .ps-input-body {
    background: #1e0a2e;
}

body.dark .form-group label {
    color: #c4b5fd;
}

body.dark .label-tip {
    color: #6d28d9;
}

body.dark .ps-select,
body.dark .ps-input {
    border-color: #3d2264;
    background-color: #2d1b4e;
    color: #e9d5ff;
}

/* 暗黑模式下拉选择框SVG箭头颜色覆盖 */
body.dark .ps-select {
    -webkit-appearance: none;
    -moz-appearance: none;
    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='%23e8ccc0' d='M6 8L2 4h8z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
}

body.dark .ps-select:focus,
body.dark .ps-input:focus {
    border-color: #7c3aed;
    background-color: #3b1f6b;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);
}

body.dark .ps-textarea {
    border-color: #3d2264;
    background: #2d1b4e;
    color: #e9d5ff;
}

body.dark .ps-textarea:focus {
    border-color: #7c3aed;
    background: #3b1f6b;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);
}

body.dark .ps-textarea::placeholder {
    color: #5b21b6;
}

body.dark .ps-textarea-hint,
body.dark #charCount {
    color: #6d28d9;
}

body.dark .ps-result-panel {
    background: #1e0a2e;
}

body.dark .panel-header {
    background: linear-gradient(to bottom, #2d1b4e 0%, #22103a 100%);
    border-bottom-color: #3d2264;
}

body.dark .ps-result-body {
    background: #1e0a2e;
}

body.dark .ps-result-body::-webkit-scrollbar-track {
    background: #1e0a2e;
}

body.dark .ps-loading-bar {
    background: linear-gradient(90deg, transparent 0%, #6d28d9 40%, #a855f7 60%, transparent 100%);
    background-size: 200% 100%;
}

body.dark .result-placeholder {
    color: #5b21b6;
}

body.dark .placeholder-title {
    color: #c4b5fd;
}

body.dark .placeholder-desc {
    color: #7c3aed;
}

body.dark .placeholder-quote {
    color: #c4b5fd;
    background: #2d1b4e;
    border-left-color: #7c3aed;
}

body.dark .loading-text {
    color: #c4b5fd;
}

body.dark .loading-dots span {
    background: #a855f7;
}

body.dark .result-content {
    color: #e9d5ff;
}

body.dark .result-content h3 {
    color: #d8b4fe;
    border-left-color: #a855f7;
    background: linear-gradient(to right, #2d1b4e, transparent);
}

body.dark .result-content h4 {
    color: #c4b5fd;
}

body.dark .result-content p {
    color: #d1d5db;
}

body.dark .result-content li {
    color: #d1d5db;
}

body.dark .result-content strong {
    color: #d8b4fe;
}

body.dark .result-content em {
    color: #c4b5fd;
}

body.dark .result-content code {
    background: #2d1b4e;
    color: #e9d5ff;
    border-color: #3d2264;
}

body.dark .result-content blockquote {
    background: #2d1b4e;
    border-left-color: #a855f7;
    color: #d1d5db;
}

body.dark .result-content hr {
    border-top-color: #2d1b4e;
}

body.dark .result-word-count {
    background: #2d1b4e;
    color: #c4b5fd;
    border-color: #3d2264;
    font-weight: 500;
}

body.dark .result-time {
    color: #a78bfa;
    background: rgba(167, 139, 250, 0.1);
}

body.dark .result-regen-btn {
    color: #c4b5fd;
    background: #2d1b4e;
    border-color: #3d2264;
}

body.dark .result-regen-btn:hover {
    background: #3b1f6b;
    border-color: #7c3aed;
}

body.dark .result-content--error {
    background: #1e0a2e;
}

body.dark .ps-error-box {
    background: #2a1212;
    border-left-color: #ef4444;
    color: #fca5a5;
}

body.dark .ps-error-box strong {
    color: #f87171;
}

body.dark .ps-error-retry-btn {
    background: #2a1212;
    border-color: #7f1d1d;
    color: #fca5a5;
}

body.dark .ps-error-retry-btn:hover {
    background: #3b1f1f;
}

body.dark .ps-modal-content {
    background: #1e0a2e;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

body.dark .ps-modal-header {
    background: linear-gradient(135deg, #2d1b4e 0%, #4c1d95 100%);
}

body.dark .ps-modal-body {
    background: #1a0533;
}

body.dark .example-card {
    background: #2d1b4e;
    border-color: #3d2264;
}

body.dark .example-card:hover {
    background: #3b1f6b;
    border-color: #7c3aed;
}

body.dark .example-card-title {
    color: #e9d5ff;
}

body.dark .example-card-desc {
    color: #9ca3af;
}

/* ========== 响应式布局 ========== */
/* 640~899px: 隐藏历史栏，保留中右两栏 */
@media (min-width: 640px) and (max-width: 899px) {
    .ps-history-panel {
        display: none;
    }
}

@media (max-width: 899px) {
    .ps-input-panel {
        width: 340px;
        flex-shrink: 0;
    }
}

/* <640px: 纵向堆叠 */
@media (max-width: 639px) {
    .ps-main-content {
        flex-direction: column;
    }
    .ps-history-panel {
        display: flex;
        width: 100%;
        max-height: 150px;
        border-right: none;
        border-bottom: 1px solid #ede9fe;
    }
    .ps-input-panel {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #ede9fe;
        max-height: 360px;
    }
    .ps-result-panel {
        min-height: 300px;
    }
    .ps-toolbar .toolbar-title {
        display: none;
    }
    .ps-modal {
        width: 95vw;
    }
    .ps-modal-body {
        grid-template-columns: 1fr;
    }
    .form-group-row {
        flex-direction: column;
    }
}

/* ========== 打印样式 ========== */
@media print {
    .ps-toolbar,
    .ps-history-panel,
    .ps-input-panel,
    .ps-modal-overlay,
    .ps-modal,
    #resultPlaceholder,
    #resultLoading {
        display: none !important;
    }
    .ps-container {
        height: auto !important;
        box-shadow: none !important;
    }
    .ps-main-content {
        display: block;
    }
    .ps-result-panel {
        width: 100%;
    }
    .ps-result-body {
        overflow: visible;
        padding: 0;
    }
}
