:root {
    --brand: #FA7800;
    --brand-dark: #d95f00;
    --bg: #f8fafc;
    --panel: #ffffff;
    --text: #1f2937;
    --muted: #64748b;
    --line: #e5e7eb;
    --soft: #fff7ed;
    --green-soft: #ecfdf5;
    --green: #059669;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

.topbar {
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 10;
}

.back-link,
.icon-btn {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 1px solid transparent;
    background: transparent;
    color: #334155;
    text-decoration: none;
    font-size: 22px;
    cursor: pointer;
}

.back-link:hover,
.icon-btn:hover {
    background: #f1f5f9;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 18px;
}

.brand img {
    width: 28px;
    height: 28px;
    border-radius: 7px;
}

.brand strong {
    min-width: 26px;
    height: 26px;
    padding: 0 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 13px;
    background: var(--soft);
    color: var(--brand-dark);
    font-size: 13px;
}

.page-shell {
    width: min(980px, calc(100vw - 32px));
    margin: 28px auto 48px;
}

.summary-panel {
    background: var(--panel);
    border: 1px solid #fed7aa;
    border-radius: 8px;
    padding: 22px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 18px;
    box-shadow: 0 8px 28px rgba(15, 23, 42, 0.04);
}

.summary-panel h1 {
    margin: 0 0 8px;
    font-size: 22px;
    line-height: 1.25;
}

.summary-panel p {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

.stats {
    display: flex;
    gap: 12px;
}

.stats div {
    min-width: 118px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px 14px;
    background: #fff;
}

.stats span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.stats strong {
    display: block;
    margin-top: 6px;
    font-size: 24px;
    color: var(--brand-dark);
}

.filters {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-btn,
.action-btn {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: #334155;
    font-weight: 800;
    padding: 10px 14px;
    cursor: pointer;
}

.filter-btn.active,
.action-btn.primary {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

.status {
    margin: 22px 0;
    padding: 28px;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    background: #fff;
    color: var(--muted);
    text-align: center;
}

.status.hidden {
    display: none;
}

.wrong-list {
    display: grid;
    gap: 14px;
}

.wrong-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
}

.wrong-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.index-badge {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: #fff1f2;
    color: #ef4444;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
}

.source-badge,
.ready-badge {
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 800;
}

.source-badge {
    background: var(--soft);
    color: var(--brand-dark);
}

.ready-badge {
    background: var(--green-soft);
    color: var(--green);
}

.question-title {
    margin: 0 0 14px;
    font-size: 18px;
    line-height: 1.65;
}

.markdown-body {
    line-height: 1.7;
    overflow-wrap: anywhere;
}

.markdown-body :first-child {
    margin-top: 0;
}

.markdown-body :last-child {
    margin-bottom: 0;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
    margin: 10px 0 8px;
    font-size: 16px;
    line-height: 1.45;
}

.markdown-body p,
.markdown-body ul,
.markdown-body ol {
    margin: 8px 0;
}

.markdown-body pre {
    max-width: 100%;
    overflow: auto;
    padding: 10px;
    border-radius: 8px;
    background: #111827;
    color: #f8fafc;
    white-space: pre;
}

.markdown-body code {
    font-family: "SFMono-Regular", Consolas, monospace;
}

.question-preview {
    color: #334155;
}

.question-details {
    margin: 8px 0 14px;
}

.question-details summary {
    width: fit-content;
    cursor: pointer;
    color: var(--brand-dark);
    font-size: 13px;
    font-weight: 900;
}

.question-details .markdown-body {
    margin-top: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}

.answer-box {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px 16px;
    font-size: 14px;
}

.answer-line {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 10px;
    font-weight: 800;
}

.answer-line span:first-child {
    color: #dc2626;
}

.answer-line span:last-child {
    color: #16a34a;
}

.analysis {
    border-top: 1px solid var(--line);
    padding-top: 10px;
    color: #475569;
    line-height: 1.7;
}

.card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.ai-panel {
    position: fixed;
    right: 28px;
    bottom: 28px;
    width: min(420px, calc(100vw - 32px));
    max-height: min(720px, calc(100vh - 56px));
    display: none;
    flex-direction: column;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.18);
    z-index: 30;
    overflow: hidden;
}

.ai-panel.open {
    display: flex;
}

.ai-panel header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 16px;
    border-bottom: 1px solid var(--line);
}

.ai-panel header strong,
.ai-panel header span {
    display: block;
}

.ai-panel header strong {
    font-size: 15px;
}

.ai-panel header span {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

.ai-panel header button {
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #64748b;
    font-size: 22px;
    cursor: pointer;
}

.ai-panel header button:hover {
    background: #f1f5f9;
}

.ai-content {
    padding: 16px;
    overflow-y: auto;
}

.ai-label {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    margin-bottom: 8px;
}

.ai-select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text);
    background: #fff;
    outline: none;
}

.ai-summary,
.ai-result,
.ai-error {
    margin-top: 14px;
    border-radius: 8px;
    padding: 14px;
}

.ai-summary {
    background: var(--soft);
    border: 1px solid #fed7aa;
}

.ai-summary strong,
.ai-summary span {
    display: block;
}

.summary-question {
    margin: 8px 0;
    color: #334155;
    line-height: 1.65;
    max-height: 132px;
    overflow: auto;
}

.ai-summary span {
    color: var(--muted);
    font-size: 12px;
}

.ai-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 14px;
}

.ai-result {
    border: 1px solid var(--line);
    background: #fff;
}

.ai-result.hint {
    border-color: #fde68a;
    background: #fffbeb;
}

.ai-result.saved {
    border-color: #bbf7d0;
    background: #f0fdf4;
}

.ai-result h3 {
    margin: 0 0 8px;
    font-size: 14px;
}

.ai-result p {
    margin: 0;
    color: #475569;
    font-size: 14px;
    line-height: 1.7;
}

.ai-result ul {
    margin: 0;
    padding-left: 18px;
    color: #475569;
    font-size: 13px;
    line-height: 1.7;
}

.recommend-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.recommend-head h3,
.recommend-head p {
    margin: 0;
}

.recommend-head p {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

.recommend-list {
    display: grid;
    gap: 10px;
}

.recommend-item {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: #f8fafc;
}

.recommend-item span,
.recommend-item em {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-style: normal;
}

.recommend-reason {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 6px 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.6;
}

.recommend-reason span {
    display: inline-flex;
    border: 1px solid #fed7aa;
    border-radius: 999px;
    padding: 3px 7px;
    background: var(--soft);
    color: var(--brand-dark);
    font-weight: 800;
}

.recommend-item strong {
    display: block;
    margin: 6px 0;
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
}

.recommend-item .question-title {
    font-size: 14px;
    margin: 6px 0 8px;
}

.practice-options {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.practice-options label {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    font-size: 13px;
    line-height: 1.5;
}

.practice-answer {
    width: 100%;
    min-height: 84px;
    margin-top: 10px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.6;
    resize: vertical;
}

.practice-submit {
    width: 100%;
    justify-content: center;
    margin-top: 10px;
}

.workspace-banner {
    border-color: #fed7aa;
    background: #fff7ed;
}

.ai-empty {
    color: var(--muted);
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    padding: 12px;
    font-size: 13px;
}

.ai-error {
    border: 1px solid #fecaca;
    background: #fef2f2;
    color: #b91c1c;
    font-size: 13px;
}

@media (max-width: 720px) {
    .topbar {
        padding: 0 14px;
    }

    .summary-panel {
        grid-template-columns: 1fr;
    }

    .stats {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .ai-panel {
        right: 16px;
        bottom: 16px;
    }

    .filter-btn {
        flex: 1 1 calc(50% - 8px);
        padding-left: 10px;
        padding-right: 10px;
    }
}
