/* ======================================================
   ultimate_brain.css - 最强大脑脑力挑战工具样式
   主题色：深紫蓝 #4f46e5 + 脑力金 #f59e0b + 翠绿 #10b981
   ====================================================== */

/* ── 整体容器 ── */
.ub-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 140px);
    min-height: 560px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 24px rgba(79, 70, 229, 0.08);
}

.ub-container.fullscreen-mode {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    height: 100vh;
    z-index: 9999;
    border-radius: 0;
    border: none;
}

/* ── 顶部工具栏 ── */
.ub-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    border-bottom: 1px solid rgba(255,255,255,0.15);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-right: 8px;
}

.toolbar-group:last-child {
    margin-left: auto;
    margin-right: 0;
}

.toolbar-title {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.5px;
    margin-right: 4px;
}

.toolbar-btn {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 6px;
    background: rgba(255,255,255,0.12);
    color: #fff;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.toolbar-btn:hover {
    background: rgba(255,255,255,0.22);
    border-color: rgba(255,255,255,0.45);
    transform: translateY(-1px);
}

.toolbar-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.toolbar-btn-primary {
    background: linear-gradient(135deg, #f59e0b, #d97706) !important;
    border-color: #f59e0b !important;
    color: #fff !important;
    font-weight: 600;
}

.toolbar-btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #fbbf24, #f59e0b) !important;
    box-shadow: 0 3px 12px rgba(245, 158, 11, 0.4);
}

.toolbar-btn-accent {
    background: linear-gradient(135deg, #10b981, #059669);
    border: none;
    color: #fff;
    padding: 7px 16px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.toolbar-btn-accent:hover {
    background: linear-gradient(135deg, #34d399, #10b981);
    box-shadow: 0 3px 12px rgba(16, 185, 129, 0.35);
    transform: translateY(-1px);
}

/* ── 主内容区三栏布局 ── */
.ub-main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ── 左栏：历史记录 ── */
.ub-history-panel {
    width: 220px;
    min-width: 180px;
    max-width: 260px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #e2e8f0;
    background: #fff;
    flex-shrink: 0;
}

.history-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: linear-gradient(to bottom, #fafafa, #f5f5f5);
    border-bottom: 1px solid #e2e8f0;
}

.history-panel-header h3 {
    margin: 0;
    font-size: 12px;
    font-weight: 600;
    color: #475569;
}

.history-count-badge {
    display: inline-block;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    font-size: 10px;
    font-weight: 600;
    background: #1f6feb;
    color: #fff;
    border-radius: 9px;
    padding: 0 4px;
    margin-left: 5px;
    vertical-align: middle;
}

.history-clear-btn {
    background: none;
    border: none;
    color: #ef4444;
    font-size: 14px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.2s;
}

.history-clear-btn:hover {
    background: #fff0f0;
}

.history-search {
    padding: 8px 10px;
    border-bottom: 1px solid #f1f5f9;
}

.history-search input {
    width: 100%;
    padding: 5px 10px;
    font-size: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    outline: none;
    background: #f8fafc;
    color: #334155;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.history-search input:focus {
    border-color: #4f46e5;
    background: #fff;
}

.history-search input::placeholder {
    color: #94a3b8;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px 0;
}

.history-empty {
    padding: 24px 16px;
    text-align: center;
    font-size: 12px;
    color: #94a3b8;
}

.history-item {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.15s;
}

.history-item:hover {
    background: #f0f4ff;
}

.history-item.active {
    background: #eef2ff;
    border-left: 3px solid #4f46e5;
    padding-left: 11px;
}

.history-item-title {
    font-size: 12px;
    font-weight: 600;
    color: #334155;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.history-item-meta {
    display: flex;
    align-items: center;
    gap: 5px;
}

.history-item-badge {
    font-size: 10px;
    font-weight: 600;
    border-radius: 4px;
    padding: 1px 5px;
    color: #fff;
}

/* 难度徽章颜色编码 - 与 getDiffBadgeClass() 返回值一致 */
.history-item-badge.diff-easy    { background: #10b981; }
.history-item-badge.diff-medium  { background: #f59e0b; }
.history-item-badge.diff-hard    { background: #f97316; }
.history-item-badge.diff-extreme { background: #ef4444; }
.history-item-badge.diff-default { background: #1f6feb; }

.history-item-time {
    font-size: 10px;
    color: #94a3b8;
}

.history-item-count {
    font-size: 10px;
    color: #6b7280;
    background: #f1f5f9;
    border-radius: 3px;
    padding: 0 4px;
}

/* ── 中栏：表单配置 ── */
.ub-input-panel {
    width: 300px;
    min-width: 260px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #e2e8f0;
    background: #fff;
}

.panel-header {
    padding: 14px 18px 10px;
    border-bottom: 1px solid #f1f5f9;
    background: linear-gradient(to bottom, #fafbff, #f6f8ff);
}

.panel-header h3 {
    margin: 0 0 4px 0;
    font-size: 13px;
    font-weight: 700;
    color: #3730a3;
}

.panel-tip {
    font-size: 11px;
    color: #6b7280;
    line-height: 1.4;
}

.ub-input-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 7px;
}

.required-mark {
    color: #ef4444;
    margin-left: 2px;
}

.label-tip {
    font-size: 11px;
    font-weight: 400;
    color: #9ca3af;
}

/* 可选字段标识 */
.mm-optional {
    font-size: 0.85em;
    font-weight: 400;
    color: #6b4030;
    margin-left: 3px;
}

/* 类型卡片网格 */
.type-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 7px;
}

.type-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 9px 4px 7px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 11px;
    color: #475569;
    gap: 3px;
}

.type-btn:hover {
    border-color: #818cf8;
    background: #eef2ff;
    color: #4f46e5;
}

.type-btn.active {
    border-color: #4f46e5;
    background: linear-gradient(135deg, #eef2ff, #f0f4ff);
    color: #4f46e5;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.18);
}

.type-icon {
    font-size: 18px;
    line-height: 1;
}

.type-label {
    font-size: 11px;
    font-weight: 600;
}

/* 难度按钮行 */
.difficulty-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.diff-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border: 1.5px solid #e2e8f0;
    border-radius: 20px;
    background: #f8fafc;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: #475569;
    transition: all 0.2s;
}

.diff-btn:hover {
    border-color: #818cf8;
    background: #eef2ff;
}

.diff-btn.active {
    border-color: #4f46e5;
    background: #eef2ff;
    color: #4f46e5;
    font-weight: 700;
}

.diff-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.diff-easy    { background: #10b981; }
.diff-medium  { background: #f59e0b; }
.diff-hard    { background: #f97316; }
.diff-extreme { background: #ef4444; }

/* 题目数量 */
.count-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ub-select {
    padding: 7px 12px;
    border: 1.5px solid #e2e8f0;
    border-radius: 6px;
    background: #f8fafc;
    color: #334155;
    font-size: 13px;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.ub-select:focus {
    border-color: #4f46e5;
}

.count-tip {
    font-size: 11px;
    color: #94a3b8;
}

/* 关键词输入 */
.ub-input {
    width: 100%;
    padding: 8px 12px;
    border: 1.5px solid #e2e8f0;
    border-radius: 6px;
    background: #f8fafc;
    color: #334155;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.ub-input:focus {
    border-color: #4f46e5;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.ub-input::placeholder {
    color: #94a3b8;
}

.keywords-hint {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 4px;
}

/* 答题区 */
.answer-section {
    margin-top: 4px;
    border: 1.5px solid #d1fae5;
    border-radius: 8px;
    background: #f0fdf4;
    padding: 12px;
}

.answer-section-header {
    margin-bottom: 8px;
}

.answer-section-header h4 {
    margin: 0 0 3px 0;
    font-size: 12px;
    font-weight: 700;
    color: #065f46;
}

.answer-tip {
    font-size: 11px;
    color: #6b7280;
}

.ub-textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1.5px solid #a7f3d0;
    border-radius: 6px;
    background: #fff;
    color: #334155;
    font-size: 13px;
    line-height: 1.6;
    outline: none;
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
    font-family: inherit;
}

.ub-textarea:focus {
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12);
}

.ub-textarea::placeholder {
    color: #94a3b8;
}

.answer-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
}

.answer-char-count {
    font-size: 11px;
    color: #94a3b8;
}

/* ── 右栏：结果展示 ── */
.ub-result-panel {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: #fff;
}

/* 结果面板头部 flex 布局规范 */
.ub-result-panel .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    min-height: 44px;
    padding: 0 18px;
}

.ub-result-panel .panel-header h3 {
    margin: 0;
}

.result-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.result-type-badge {
    font-size: 11px;
    font-weight: 600;
    background: #eef2ff;
    color: #4f46e5;
    border-radius: 4px;
    padding: 2px 7px;
    border: 1px solid #c7d2fe;
}

.result-diff-badge {
    font-size: 11px;
    font-weight: 600;
    border-radius: 4px;
    padding: 2px 7px;
    border: 1px solid;
}

/* 结果区难度徽章颜色编码 */
.result-diff-badge.diff-easy    { background: #d1fae5; color: #065f46; border-color: #a7f3d0; }
.result-diff-badge.diff-medium  { background: #fef3c7; color: #d97706; border-color: #fde68a; }
.result-diff-badge.diff-hard    { background: #ffedd5; color: #c2410c; border-color: #fed7aa; }
.result-diff-badge.diff-extreme { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
.result-diff-badge.diff-default { background: #fef3c7; color: #d97706; border-color: #fde68a; }

.result-time {
    font-size: 11px;
    color: #94a3b8;
}

.ub-result-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
}

/* 占位状态 */
.result-placeholder {
    height: 100%;
    min-height: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 8px;
}

.brain-animation {
    margin-bottom: 10px;
}

.brain-pulse {
    font-size: 56px;
    animation: brainPulse 2s ease-in-out infinite;
    display: inline-block;
}

@keyframes brainPulse {
    0%, 100% { transform: scale(1); }
    50%       { transform: scale(1.12); }
}

.placeholder-title {
    font-size: 16px;
    font-weight: 700;
    color: #374151;
    margin: 0;
}

.placeholder-desc {
    font-size: 13px;
    color: #6b7280;
    margin: 0;
    max-width: 300px;
}

.quick-start-tips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 12px;
}

.tip-item {
    background: #eef2ff;
    color: #4f46e5;
    font-size: 12px;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 12px;
    border: 1px solid #c7d2fe;
}

/* 加载状态 */
.result-loading {
    height: 100%;
    min-height: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.loading-brain {
    font-size: 48px;
    animation: brainSpin 1.5s ease-in-out infinite alternate;
    display: inline-block;
}

@keyframes brainSpin {
    0%   { transform: rotate(-8deg) scale(1); }
    100% { transform: rotate(8deg) scale(1.08); }
}

.loading-dots {
    display: flex;
    gap: 6px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4f46e5;
    animation: dotBounce 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 dotBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40%           { transform: scale(1); opacity: 1; }
}

.loading-text {
    font-size: 14px;
    color: #6b7280;
    margin: 0;
}

/* 结果内容 */
.result-content {
    animation: fadeInUp 0.4s ease-out;
}

.eval-result {
    margin-top: 24px;
    border-top: 2px solid #d1fae5;
    padding-top: 20px;
    animation: fadeInUp 0.4s ease-out;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Markdown 渲染样式 ── */
.ub-markdown h2 {
    font-size: 17px;
    font-weight: 700;
    color: #3730a3;
    margin: 20px 0 10px;
    padding-bottom: 6px;
    border-bottom: 2px solid #e0e7ff;
}

.ub-markdown h3 {
    font-size: 15px;
    font-weight: 700;
    color: #4f46e5;
    margin: 18px 0 8px;
    background: linear-gradient(to right, #eef2ff, transparent);
    padding: 6px 10px;
    border-left: 3px solid #4f46e5;
    border-radius: 0 4px 4px 0;
}

.ub-markdown h4 {
    font-size: 13px;
    font-weight: 700;
    color: #374151;
    margin: 12px 0 6px;
}

.ub-markdown h5 {
    font-size: 13px;
    font-weight: 600;
    color: #4b5563;
    margin: 10px 0 5px;
}

.ub-markdown p {
    font-size: 14px;
    color: #374151;
    line-height: 1.75;
    margin: 8px 0;
}

.ub-markdown strong {
    font-weight: 700;
    color: #1e1b4b;
}

.ub-markdown em {
    color: #7c3aed;
    font-style: italic;
}

.ub-markdown ul, .ub-markdown ol {
    margin: 8px 0 8px 20px;
    padding: 0;
}

.ub-markdown li {
    font-size: 14px;
    color: #374151;
    line-height: 1.7;
    margin-bottom: 4px;
}

.ub-markdown blockquote {
    margin: 12px 0;
    padding: 10px 16px;
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
    border-radius: 0 6px 6px 0;
    color: #78350f;
    font-size: 13px;
}

.ub-markdown code {
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 12px;
    color: #7c3aed;
    border: 1px solid #e2e8f0;
}

.ub-markdown pre {
    background: #1e1b4b;
    padding: 14px 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 10px 0;
}

.ub-markdown pre code {
    background: none;
    border: none;
    color: #c4b5fd;
    font-size: 13px;
    padding: 0;
}

.ub-markdown hr {
    border: none;
    border-top: 1.5px dashed #c7d2fe;
    margin: 18px 0;
}

.ub-markdown a {
    color: #4f46e5;
    text-decoration: none;
    border-bottom: 1px solid #c7d2fe;
}

.ub-markdown a:hover {
    color: #3730a3;
    border-color: #4f46e5;
}

/* 表格 */
.ub-markdown .ub-table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 13px;
    overflow: hidden;
}

.ub-markdown .ub-table th {
    background: #eef2ff;
    color: #3730a3;
    font-weight: 700;
    padding: 8px 12px;
    text-align: left;
    border: 1px solid #c7d2fe;
}

.ub-markdown .ub-table td {
    padding: 7px 12px;
    border: 1px solid #e2e8f0;
    color: #374151;
    vertical-align: top;
    line-height: 1.6;
}

.ub-markdown .ub-table tr:nth-child(even) td {
    background: #f8fafc;
}

/* ── 输入框抖动动画 ── */
@keyframes shakeAnim {
    0%, 100% { transform: translateX(0); }
    15%       { transform: translateX(-6px); }
    30%       { transform: translateX(6px); }
    45%       { transform: translateX(-5px); }
    60%       { transform: translateX(5px); }
    75%       { transform: translateX(-3px); }
    90%       { transform: translateX(3px); }
}

.shake-input {
    animation: shakeAnim 0.5s ease;
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2) !important;
}

/* ── 模态框 ── */
@keyframes meOverlayFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes meModalSlideIn {
    from { opacity: 0; transform: translate(-50%, -48%) scale(0.94); }
    to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.ub-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 10000;
    animation: meOverlayFadeIn 0.22s ease-out forwards;
}

.ub-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10001;
    width: 680px;
    max-width: calc(100vw - 40px);
    max-height: 80vh;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(79, 70, 229, 0.22);
    display: flex;
    flex-direction: column;
    animation: meModalSlideIn 0.28s cubic-bezier(.34,1.4,.64,1) forwards;
    overflow: hidden;
}

.ub-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
    background: linear-gradient(135deg, #eef2ff, #f0f4ff);
}

.ub-modal-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: #3730a3;
}

.ub-modal-close {
    background: none;
    border: none;
    font-size: 16px;
    color: #6b7280;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
}

.ub-modal-close:hover {
    background: #fee2e2;
    color: #ef4444;
}

.ub-modal-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.ub-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    align-content: start;
}

.example-card {
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    padding: 14px;
    cursor: pointer;
    transition: all 0.2s;
    background: #fafbff;
}

.example-card:hover {
    border-color: #818cf8;
    background: #eef2ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(79, 70, 229, 0.12);
}

.example-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.example-icon {
    font-size: 22px;
}

.example-title {
    font-size: 13px;
    font-weight: 700;
    color: #334155;
}

.example-badges {
    display: flex;
    gap: 5px;
    margin-bottom: 7px;
}

.example-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 4px;
    background: #eef2ff;
    color: #4f46e5;
    border: 1px solid #c7d2fe;
}

.example-badge.diff {
    background: #fef3c7;
    color: #d97706;
    border-color: #fde68a;
}

.example-desc {
    font-size: 11px;
    color: #6b7280;
    line-height: 1.5;
}

/* 错误提示语义化类 */
.ub-result-error-block {
    padding: 18px 20px;
    background: #fff0f0;
    border: 1px solid #fca5a5;
    border-left: 4px solid #ef4444;
    border-radius: 8px;
    color: #b91c1c;
    font-size: 14px;
    line-height: 1.6;
}

.ub-result-error-block::before {
    content: '⚠️ ';
    font-size: 15px;
}

.ub-error-retry-btn {
    display: inline-block;
    margin-top: 12px;
    padding: 6px 14px;
    background: #ef4444;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.ub-error-retry-btn:hover {
    background: #dc2626;
    transform: translateY(-1px);
}

/* ── Toast 提示 ── */
.ub-toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 99999;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #fff;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    animation: toastIn 0.3s ease-out;
    max-width: 320px;
}

.ub-toast.success { background: #10b981; }
.ub-toast.error   { background: #ef4444; }
.ub-toast.info    { background: #4f46e5; }
.ub-toast.warning { background: #f59e0b; }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── 暗黑模式 ── */
body.dark .ub-container {
    background: #0f172a;
    border-color: #1e293b;
    box-shadow: 0 4px 24px rgba(0,0,0,0.4);
}

body.dark .ub-toolbar {
    background: linear-gradient(135deg, #312e81 0%, #4c1d95 100%);
    border-bottom-color: rgba(255,255,255,0.08);
}

body.dark .ub-main-content {
    background: #0f172a;
}

body.dark .ub-history-panel {
    background: #1e293b;
    border-right-color: #334155;
}

body.dark .history-panel-header {
    background: linear-gradient(to bottom, #1e293b, #172033);
    border-bottom-color: #334155;
}

body.dark .history-panel-header h3 {
    color: #94a3b8;
}

body.dark .history-count-badge {
    background: #1f6feb;
}

body.dark .history-search {
    border-bottom-color: #1e293b;
}

body.dark .history-search input {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}

body.dark .history-search input::placeholder {
    color: #475569;
}

body.dark .history-search input:focus {
    border-color: #818cf8;
    background: #1e293b;
}

body.dark .history-item {
    border-bottom-color: #1e293b;
    color: #cbd5e1;
}

body.dark .history-item:hover {
    background: #1e2d4a;
}

body.dark .history-item.active {
    background: #1e2d4a;
    border-left-color: #818cf8;
}

body.dark .history-item-title {
    color: #e2e8f0;
}

body.dark .history-item-badge.diff-easy    { background: #059669; color: #d1fae5; }
body.dark .history-item-badge.diff-medium  { background: #d97706; color: #fef3c7; }
body.dark .history-item-badge.diff-hard    { background: #ea580c; color: #ffedd5; }
body.dark .history-item-badge.diff-extreme { background: #dc2626; color: #fee2e2; }
body.dark .history-item-badge.diff-default { background: #1f6feb; color: #fff; }

body.dark .history-item-time {
    color: #475569;
}

body.dark .history-item-count {
    color: #94a3b8;
    background: #0f172a;
}

body.dark .history-empty {
    color: #475569;
}

body.dark .ub-input-panel {
    background: #1e293b;
    border-right-color: #334155;
}

body.dark .panel-header {
    background: linear-gradient(to bottom, #1e293b, #172033);
    border-bottom-color: #334155;
}

body.dark .panel-header h3 {
    color: #818cf8;
}

body.dark .panel-tip {
    color: #475569;
}

body.dark .ub-input-body {
    background: #1e293b;
}

body.dark .form-group label {
    color: #cbd5e1;
}

body.dark .label-tip {
    color: #475569;
}

body.dark .mm-optional {
    color: #b89a8c;
}

body.dark .type-btn {
    background: #0f172a;
    border-color: #334155;
    color: #94a3b8;
}

body.dark .type-btn:hover {
    border-color: #818cf8;
    background: #1e2d4a;
    color: #818cf8;
}

body.dark .type-btn.active {
    border-color: #818cf8;
    background: linear-gradient(135deg, #1e2d4a, #1e293b);
    color: #a5b4fc;
    box-shadow: 0 2px 8px rgba(129, 140, 248, 0.2);
}

body.dark .diff-btn {
    background: #0f172a;
    border-color: #334155;
    color: #94a3b8;
}

body.dark .diff-btn:hover {
    border-color: #818cf8;
    background: #1e2d4a;
}

body.dark .diff-btn.active {
    border-color: #818cf8;
    background: #1e2d4a;
    color: #a5b4fc;
}

body.dark .ub-select {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}

body.dark .ub-select:focus {
    border-color: #818cf8;
}

body.dark .count-tip {
    color: #475569;
}

body.dark .ub-input {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}

body.dark .ub-input:focus {
    border-color: #818cf8;
    background: #1e293b;
    box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.15);
}

body.dark .ub-input::placeholder {
    color: #475569;
}

body.dark .keywords-hint {
    color: #475569;
}

body.dark .answer-section {
    background: #0d2818;
    border-color: #14532d;
}

body.dark .answer-tip {
    color: #86efac;
}

body.dark .answer-section-header h4 {
    color: #6ee7b7;
}

body.dark .ub-textarea {
    background: #0f172a;
    border-color: #166534;
    color: #e2e8f0;
}

body.dark .ub-textarea:focus {
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

body.dark .ub-textarea::placeholder {
    color: #475569;
}

body.dark .answer-char-count {
    color: #475569;
}

body.dark .ub-result-panel {
    background: #1e293b;
}

body.dark .ub-result-panel .panel-header h3 {
    color: #818cf8;
}

body.dark .result-type-badge {
    background: #1e2d4a;
    color: #818cf8;
    border-color: #3730a3;
}

body.dark .result-diff-badge.diff-easy    { background: #064e3b; color: #6ee7b7; border-color: #065f46; }
body.dark .result-diff-badge.diff-medium  { background: #2d2006; color: #fbbf24; border-color: #78350f; }
body.dark .result-diff-badge.diff-hard    { background: #431407; color: #fb923c; border-color: #7c2d12; }
body.dark .result-diff-badge.diff-extreme { background: #450a0a; color: #f87171; border-color: #7f1d1d; }
body.dark .result-diff-badge.diff-default { background: #2d2006; color: #fbbf24; border-color: #78350f; }

body.dark .result-time {
    color: #475569;
}

body.dark .ub-result-body {
    background: #1e293b;
}

body.dark .result-placeholder {
    background: #1e293b;
}

body.dark .placeholder-title {
    color: #e2e8f0;
}

body.dark .placeholder-desc {
    color: #475569;
}

body.dark .tip-item {
    background: #1e2d4a;
    color: #818cf8;
    border-color: #3730a3;
}

body.dark .loading-text {
    color: #94a3b8;
}

body.dark .loading-dots span {
    background: #818cf8;
}

/* 暗黑 Markdown */
body.dark .ub-markdown h2 {
    color: #a5b4fc;
    border-bottom-color: #334155;
}

body.dark .ub-markdown h3 {
    color: #818cf8;
    background: linear-gradient(to right, #1e2d4a, transparent);
    border-left-color: #818cf8;
}

body.dark .ub-markdown h4 {
    color: #cbd5e1;
}

body.dark .ub-markdown h5 {
    color: #94a3b8;
}

body.dark .ub-markdown p {
    color: #cbd5e1;
}

body.dark .ub-markdown strong {
    color: #e2e8f0;
}

body.dark .ub-markdown em {
    color: #c4b5fd;
}

body.dark .ub-markdown li {
    color: #cbd5e1;
}

body.dark .ub-markdown blockquote {
    background: #2d2006;
    border-left-color: #f59e0b;
    color: #fcd34d;
}

body.dark .ub-markdown code {
    background: #0f172a;
    color: #c4b5fd;
    border-color: #334155;
}

body.dark .ub-markdown hr {
    border-top-color: #334155;
}

body.dark .ub-markdown a {
    color: #818cf8;
    border-bottom-color: #3730a3;
}

body.dark .eval-result {
    border-top-color: #14532d;
}

body.dark .ub-markdown .ub-table th {
    background: #1e2d4a;
    color: #a5b4fc;
    border-color: #334155;
}

body.dark .ub-markdown .ub-table td {
    border-color: #334155;
    color: #cbd5e1;
}

body.dark .ub-markdown .ub-table tr:nth-child(even) td {
    background: #0f172a;
}

body.dark .ub-result-error-block {
    background: #2d0a0a;
    border-color: #7f1d1d;
    border-left-color: #ef4444;
    color: #fca5a5;
}

body.dark .ub-error-retry-btn {
    background: #b91c1c;
}

body.dark .ub-error-retry-btn:hover {
    background: #991b1b;
}

/* 暗黑模态框 */
body.dark .ub-modal {
    background: #1e293b;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

body.dark .ub-modal-header {
    background: linear-gradient(135deg, #1e2d4a, #1e293b);
    border-bottom-color: #334155;
}

body.dark .ub-modal-header h3 {
    color: #818cf8;
}

body.dark .ub-modal-close {
    color: #94a3b8;
}

body.dark .ub-modal-body {
    background: #1e293b;
}

body.dark .example-card {
    background: #0f172a;
    border-color: #334155;
}

body.dark .example-card:hover {
    border-color: #818cf8;
    background: #1e2d4a;
}

body.dark .example-title {
    color: #e2e8f0;
}

body.dark .example-desc {
    color: #475569;
}

body.dark .example-badge {
    background: #1e2d4a;
    color: #818cf8;
    border-color: #3730a3;
}

body.dark .example-badge.diff {
    background: #2d2006;
    color: #fbbf24;
    border-color: #78350f;
}

/* ── 响应式：≤639px ── */
@media (max-width: 639px) {
    .ub-main-content {
        flex-direction: column;
    }

    .ub-history-panel {
        width: 100%;
        max-width: 100%;
        max-height: 180px;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
    }

    .ub-input-panel {
        width: 100%;
        min-width: 0;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
    }

    .type-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .ub-modal-body {
        grid-template-columns: 1fr;
    }

    .ub-container {
        height: auto;
        min-height: unset;
    }
}

body.dark .ub-history-panel {
    border-bottom-color: #334155;
}

body.dark .ub-input-panel {
    border-bottom-color: #334155;
}