:root {
    --bg-top: #f8fbff;
    --bg-bottom: #eef5ff;
    --ink-main: #132238;
    --ink-muted: #5d6b82;
    --line: #d8e3f2;
    --primary: #0a84ff;
    --primary-dark: #055ec4;
    --surface: rgba(255, 255, 255, 0.86);
    --surface-strong: #ffffff;
    --shadow-soft: 0 18px 45px rgba(11, 35, 76, 0.1);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink-main);
    font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
    background:
        radial-gradient(1200px 500px at -12% -8%, rgba(10, 132, 255, 0.2), transparent 60%),
        radial-gradient(900px 440px at 110% -6%, rgba(255, 126, 51, 0.22), transparent 56%),
        linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
    min-height: 100vh;
}

h1, h2, h3, h4, h5 {
    font-family: "Noto Serif SC", "Songti SC", "STSong", serif;
    color: #0d1b2a;
}

.top-nav {
    background: linear-gradient(95deg, #0c76dd, #0662bf);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.top-nav .navbar-brand {
    letter-spacing: 0.03em;
}

.btn-brand {
    border: 0;
    border-radius: 999px;
    color: #ffffff;
    background: linear-gradient(90deg, #ff7d33, #ff5e1f);
    padding: 0.5rem 1rem;
    box-shadow: 0 10px 20px rgba(255, 97, 31, 0.25);
}

.btn-brand:hover {
    color: #ffffff;
    transform: translateY(-1px);
}

.hero-card {
    border: 1px solid rgba(255, 255, 255, 0.85);
    border-radius: 1.15rem;
    background: var(--surface);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-soft);
    padding: 1.35rem 1.4rem;
    animation: float-up 0.45s ease-out;
}

.muted-note {
    color: var(--ink-muted);
}

.subject-grid .subject-card {
    border: 1px solid var(--line);
    border-radius: 1rem;
    overflow: hidden;
    background: var(--surface-strong);
    box-shadow: 0 10px 24px rgba(13, 37, 72, 0.08);
    animation: float-up 0.45s ease-out;
}

.subject-grid .subject-head {
    border-bottom: 1px solid #edf2fb;
    border-top: 4px solid var(--subject-accent, #0a84ff);
    background: linear-gradient(90deg, rgba(10, 132, 255, 0.08), rgba(255, 255, 255, 0.8));
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    font-weight: 700;
}

.subject-count {
    color: var(--subject-accent, #0a84ff);
    font-size: 0.85rem;
    font-weight: 700;
}

.subject-list {
    list-style: none;
    margin: 0;
    padding: 0.3rem 0.85rem 0.9rem;
}

.subject-item {
    border-bottom: 1px dashed #e8effa;
}

.subject-item:last-child {
    border-bottom: 0;
}

.subject-link {
    display: block;
    text-decoration: none;
    color: #1b3b61;
    padding: 0.7rem 0.25rem;
    transition: all 0.2s ease;
}

.subject-link:hover {
    color: #0a66cc;
    transform: translateX(3px);
}

.subject-link small {
    color: #6a7890;
}

.subject-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.item-actions {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
}

.item-actions form {
    margin: 0;
}

.empty-tip {
    color: #7788a2;
    margin: 0;
    padding: 1rem;
}

.panel-card {
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 1rem;
    background: var(--surface);
    backdrop-filter: blur(8px);
    box-shadow: var(--shadow-soft);
}

.code-area {
    font-family: "JetBrains Mono", "Consolas", "Courier New", monospace;
    font-size: 0.92rem;
    line-height: 1.55;
    min-height: 360px;
}

.subject-pill {
    display: inline-block;
    font-size: 0.8rem;
    line-height: 1;
    border-radius: 999px;
    padding: 0.3rem 0.6rem;
    background: #e8f2ff;
    color: #0a68cb;
}

.preview-shell {
    border: 1px solid #d9e4f5;
    border-radius: 1rem;
    background: #ffffff;
    box-shadow: 0 14px 34px rgba(10, 31, 63, 0.1);
    overflow: hidden;
}

.preview-head {
    background: linear-gradient(90deg, #f3f7ff, #fbfcff);
    border-bottom: 1px solid #e6edf9;
    padding: 0.8rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.rendered-content {
    min-height: 480px;
    padding: 1rem;
    overflow: auto;
    background: #ffffff;
}

.source-code {
    margin: 0;
    min-height: 480px;
    padding: 1rem;
    overflow: auto;
    background: #f7faff;
    border-left: 1px solid #e4ecf8;
    font-family: "JetBrains Mono", "Consolas", "Courier New", monospace;
    font-size: 0.87rem;
    color: #1f3250;
}

.btn-outline-soft {
    border: 1px solid #c8d8ed;
    color: #33506f;
    background: #f7fbff;
}

.btn-outline-soft:hover {
    background: #eef5ff;
    color: #24486f;
}

.view-body {
    background:
        radial-gradient(1000px 420px at 15% -10%, rgba(10, 132, 255, 0.12), transparent 58%),
        radial-gradient(950px 400px at 95% -8%, rgba(16, 185, 129, 0.12), transparent 56%),
        #f6f9ff;
}

.view-toolbar {
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(8px);
    background: rgba(246, 249, 255, 0.82);
    border-bottom: 1px solid #dce7f7;
}

.view-toolbar form {
    margin: 0;
}

.view-hero {
    border: 1px solid #d9e6f8;
    border-radius: 0.95rem;
    background: rgba(255, 255, 255, 0.88);
    padding: 1rem 1.15rem;
    box-shadow: 0 10px 26px rgba(19, 39, 73, 0.08);
}

.preview-clean {
    border-color: #d5e2f5;
}

.rendered-content-lg {
    min-height: 68vh;
}

.source-panel {
    border-top: 1px solid #e3ecfa;
    background: #f9fbff;
}

.source-panel summary {
    list-style: none;
    cursor: pointer;
    padding: 0.75rem 1rem;
    color: #2b476d;
    font-weight: 600;
    user-select: none;
}

.source-panel summary::-webkit-details-marker {
    display: none;
}

.source-code-inline {
    margin: 0;
    min-height: 260px;
    border-left: 0;
    border-top: 1px solid #e4ecf8;
    background: #f5f9ff;
}

@keyframes float-up {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 992px) {
    .code-area {
        min-height: 300px;
    }

    .rendered-content,
    .source-code {
        min-height: 340px;
    }

    .source-code {
        border-left: 0;
        border-top: 1px solid #e4ecf8;
    }

    .subject-row {
        flex-direction: column;
        align-items: flex-start;
    }
}
