* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: #f7f8fa;
    color: #1f2937;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.6;
}

a {
    color: #2563eb;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 14px 28px;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
}

.brand {
    color: #111827;
    font-weight: 700;
}

.topbar nav,
.actions,
.toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.container {
    max-width: 1120px;
    margin: 0 auto;
    padding: 28px;
}

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 20px;
}

h1,
h2 {
    margin: 0 0 10px;
    color: #111827;
}

h1 {
    font-size: 28px;
}

h2 {
    font-size: 18px;
}

p {
    margin: 0 0 12px;
}

.panel,
.card,
.empty {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 20px;
}

.upload-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 420px;
    gap: 28px;
    align-items: start;
    padding: 34px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.upload-hero h1 {
    font-size: 34px;
    line-height: 1.25;
}

.upload-hero p {
    max-width: 620px;
    color: #4b5563;
    font-size: 17px;
}

.upload-box {
    padding: 18px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #f9fafb;
}

.upload-box p {
    display: grid;
    gap: 6px;
}

.recent-panel {
    margin-top: 20px;
}

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

.recent-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 0;
    border-top: 1px solid #eef2f7;
}

.recent-item:first-child {
    border-top: 0;
    padding-top: 0;
}

.recent-item strong,
.recent-item span {
    display: block;
}

.recent-item span {
    color: #6b7280;
    font-size: 14px;
}

.chapter-progress-list {
    display: grid;
    gap: 12px;
}

.chapter-progress-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 14px;
    border: 1px solid #e5eaf2;
    border-radius: 8px;
    background: #f8fbff;
}

.chapter-progress-item strong,
.chapter-progress-item span {
    display: block;
}

.chapter-progress-item span {
    color: #64748b;
    font-size: 14px;
}

.loading-panel {
    display: grid;
    justify-items: center;
    gap: 12px;
    padding: 56px 24px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    text-align: center;
}

.spinner {
    width: 46px;
    height: 46px;
    border: 4px solid #dbeafe;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.result-links {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}

.result-card {
    display: grid;
    gap: 8px;
    min-height: 130px;
    padding: 20px;
    border: 1px solid #dbeafe;
    border-radius: 8px;
    background: #ffffff;
    color: #111827;
}

.result-card:hover {
    border-color: #2563eb;
    text-decoration: none;
}

.result-card strong {
    font-size: 20px;
}

.result-card span {
    color: #4b5563;
}

.card-main-link {
    align-self: end;
    font-weight: 700;
}

.card-sub-link {
    width: fit-content;
    font-size: 14px;
    color: #6b7280;
}

.narrow {
    max-width: 520px;
    margin: 40px auto;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.two-column {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.toolbar {
    margin-bottom: 16px;
}

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 7px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #ffffff;
    color: #111827;
    cursor: pointer;
    font: inherit;
}

button:hover,
.button:hover {
    background: #f3f4f6;
    text-decoration: none;
}

.primary {
    border-color: #2563eb;
    background: #2563eb;
    color: #ffffff;
}

.primary:hover {
    background: #1d4ed8;
}

.inline-form {
    display: inline;
}

.form-card p {
    display: grid;
    gap: 6px;
    margin-bottom: 14px;
}

input,
select,
textarea {
    width: 100%;
    padding: 9px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #ffffff;
    font: inherit;
}

textarea {
    resize: vertical;
}

.helptext {
    color: #6b7280;
    font-size: 13px;
}

.errorlist {
    margin: 0 0 8px;
    padding-left: 18px;
    color: #b91c1c;
}

.messages {
    margin-bottom: 18px;
}

.message {
    padding: 10px 12px;
    border-radius: 6px;
    margin-bottom: 8px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
}

.message.error {
    background: #fef2f2;
    border-color: #fecaca;
}

.message.success {
    background: #ecfdf5;
    border-color: #a7f3d0;
}

.status-list {
    display: grid;
    grid-template-columns: 140px minmax(0, 1fr);
    gap: 10px 18px;
    margin: 0;
}

.status-list dt {
    color: #6b7280;
}

.status-list dd {
    margin: 0;
}

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

.task-row {
    display: grid;
    gap: 8px;
}

.task-row > div:first-child {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.error-text {
    color: #b91c1c;
    word-break: break-word;
}

.muted,
.meta {
    color: #6b7280;
}

.meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 14px;
    font-size: 14px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 10px 8px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
}

.list {
    margin: 0;
    padding-left: 20px;
}

.list li {
    margin-bottom: 8px;
}

.question-list > li {
    margin-bottom: 18px;
}

.study-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
}

.study-card {
    padding: 16px;
    border: 1px solid #e0e7f0;
    border-radius: 8px;
    background: #f8fbff;
}

.study-card strong {
    display: block;
    margin-bottom: 8px;
    color: #0f172a;
    font-size: 17px;
}

.study-card p {
    margin: 0;
}

.branch-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 14px;
}

.branch-card {
    padding: 18px;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.branch-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.branch-card-head a {
    color: #1d4ed8;
    font-weight: 800;
}

.branch-card-head span {
    flex: 0 0 auto;
    padding: 3px 8px;
    border-radius: 999px;
    background: #eaf2ff;
    color: #315f99;
    font-size: 13px;
    font-weight: 700;
}

.branch-card p {
    margin: 0 0 12px;
}

.branch-card blockquote {
    margin: 0 0 12px;
    padding: 12px 14px;
    border-left: 4px solid #93c5fd;
    background: #f1f6fd;
    color: #344256;
}

.mini-question-list {
    margin: 0;
    padding-left: 18px;
    color: #344256;
}

.mini-question-list li {
    margin-bottom: 6px;
}

.question-meta {
    margin-bottom: 6px;
    color: #6b7280;
    font-size: 13px;
}

details {
    margin-top: 8px;
}

summary {
    color: #2563eb;
    cursor: pointer;
}

.quiz-form {
    display: grid;
    gap: 14px;
}

.quiz-form label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
}

.quiz-results {
    display: grid;
    gap: 10px;
    margin-bottom: 22px;
}

.quiz-ok,
.quiz-bad {
    padding: 12px;
    border-radius: 6px;
}

.quiz-ok {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
}

.quiz-bad {
    background: #fff7ed;
    border: 1px solid #fed7aa;
}

.tree,
.tree ul {
    list-style: none;
    margin: 0;
    padding-left: 22px;
}

.tree {
    padding-left: 0;
}

.tree li {
    position: relative;
    margin: 8px 0;
}

.tree li::before {
    content: "";
    position: absolute;
    top: 18px;
    left: -14px;
    width: 10px;
    border-top: 1px solid #cbd5e1;
}

.tree > li::before {
    display: none;
}

.tree-node {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid #dbeafe;
    border-radius: 6px;
    background: #ffffff;
}

.tree-node span {
    color: #6b7280;
    font-size: 13px;
}

.star-head {
    align-items: center;
}

.star-map {
    position: relative;
    min-height: 720px;
    margin-bottom: 22px;
    overflow: hidden;
    border: 1px solid rgba(125, 211, 252, 0.28);
    border-radius: 8px;
    background:
        radial-gradient(circle at 22% 18%, rgba(56, 189, 248, 0.22), transparent 28%),
        radial-gradient(circle at 78% 26%, rgba(167, 139, 250, 0.2), transparent 30%),
        radial-gradient(circle at 50% 80%, rgba(45, 212, 191, 0.14), transparent 34%),
        linear-gradient(135deg, #08111f 0%, #111827 48%, #07101d 100%);
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
}

.star-map::after {
    content: "";
    position: absolute;
    inset: -20%;
    z-index: 2;
    pointer-events: none;
    background: radial-gradient(circle at center, rgba(255, 255, 255, 0.24), rgba(125, 211, 252, 0.1) 18%, transparent 42%);
    opacity: 0;
    transform: scale(1.35);
    transition: opacity 180ms ease, transform 360ms ease;
}

.star-map.is-diving::after {
    opacity: 1;
    transform: scale(0.72);
}

.starfield,
.star-links,
.star-nodes {
    position: absolute;
    inset: 0;
}

.star-nodes {
    z-index: 3;
    transition: opacity 180ms ease, transform 260ms ease;
}

.star-map.is-diving .star-nodes {
    opacity: 0.38;
    transform: scale(1.04);
}

.star-links {
    width: 100%;
    height: 100%;
    z-index: 1;
    transition: opacity 180ms ease;
}

.star-map.is-diving .star-links {
    opacity: 0.28;
}

.star-link {
    stroke: rgba(186, 230, 253, 0.34);
    stroke-width: 1.1;
    transition: opacity 180ms ease, stroke-width 180ms ease;
}

.star-link.chapter {
    stroke: rgba(251, 191, 36, 0.42);
    stroke-width: 1.4;
}

.star-node {
    position: absolute;
    display: grid;
    width: auto;
    max-width: 150px;
    min-height: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: #e0f2fe;
    text-align: center;
    transform: translate(-50%, -50%);
    cursor: pointer;
    filter: drop-shadow(0 0 14px rgba(96, 165, 250, 0.28));
    transition: left 360ms ease, top 360ms ease, transform 180ms ease, opacity 180ms ease;
}

.star-node:hover,
.star-node.is-active {
    background: transparent;
    color: #ffffff;
    text-decoration: none;
    transform: translate(-50%, -50%) scale(1.06);
}

.star-node span {
    display: block;
    width: 14px;
    height: 14px;
    margin: 0 auto 7px;
    border-radius: 999px;
    background: #bfdbfe;
    box-shadow:
        0 0 0 5px rgba(59, 130, 246, 0.18),
        0 0 24px rgba(147, 197, 253, 0.85);
}

.star-node strong {
    display: block;
    padding: 4px 7px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.54);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.25;
    backdrop-filter: blur(8px);
}

.star-node.book span {
    width: 44px;
    height: 44px;
    background: #fde68a;
    box-shadow:
        0 0 0 14px rgba(251, 191, 36, 0.16),
        0 0 64px rgba(251, 191, 36, 0.92);
}

.star-node.book strong {
    font-size: 17px;
    color: #fef3c7;
}

.star-node.chapter span {
    width: 28px;
    height: 28px;
    background: #67e8f9;
    box-shadow:
        0 0 0 10px rgba(6, 182, 212, 0.17),
        0 0 44px rgba(103, 232, 249, 0.86);
}

.star-node.chapter strong {
    max-width: 132px;
}

.star-map.is-zoomed .star-node.chapter span {
    width: 42px;
    height: 42px;
    background: #22d3ee;
    box-shadow:
        0 0 0 14px rgba(34, 211, 238, 0.16),
        0 0 62px rgba(103, 232, 249, 0.94);
}

.star-map.is-zoomed .star-node.chapter strong {
    font-size: 16px;
}

.star-node.module span {
    width: 26px;
    height: 26px;
    background: #a5b4fc;
    box-shadow:
        0 0 0 9px rgba(99, 102, 241, 0.18),
        0 0 40px rgba(165, 180, 252, 0.88);
}

.star-node.module strong {
    font-size: 14px;
}

.star-map.is-zoomed .star-node.module span {
    width: 30px;
    height: 30px;
}

.star-map.is-zoomed .star-node.module.is-center span {
    width: 40px;
    height: 40px;
    background: #c4b5fd;
    box-shadow:
        0 0 0 13px rgba(139, 92, 246, 0.18),
        0 0 58px rgba(196, 181, 253, 0.92);
}

.star-node.major span {
    width: 18px;
    height: 18px;
    background: #c4b5fd;
    box-shadow:
        0 0 0 7px rgba(139, 92, 246, 0.17),
        0 0 30px rgba(196, 181, 253, 0.82);
}

.star-map.is-zoomed .star-node.major span,
.star-map.is-zoomed .star-node.point span {
    width: 18px;
    height: 18px;
}

.star-node.is-active span {
    background: #ffffff;
    box-shadow:
        0 0 0 8px rgba(255, 255, 255, 0.14),
        0 0 46px rgba(255, 255, 255, 0.92);
}

.star-inspector {
    position: absolute;
    right: 22px;
    bottom: 22px;
    z-index: 4;
    width: min(330px, calc(100% - 44px));
    padding: 18px;
    border: 1px solid rgba(186, 230, 253, 0.24);
    border-radius: 8px;
    background: rgba(8, 17, 31, 0.74);
    color: #dbeafe;
    backdrop-filter: blur(14px);
}

.star-inspector span {
    display: block;
    margin-bottom: 6px;
    color: #93c5fd;
    font-size: 12px;
}

.star-inspector strong {
    display: block;
    margin-bottom: 8px;
    color: #ffffff;
    font-size: 18px;
}

.star-inspector p {
    color: #bfdbfe;
    font-size: 14px;
}

.star-inspector a {
    color: #fde68a;
    font-weight: 700;
}

.star-back {
    position: absolute;
    top: 18px;
    left: 18px;
    z-index: 5;
    border-color: rgba(186, 230, 253, 0.28);
    background: rgba(8, 17, 31, 0.68);
    color: #e0f2fe;
    backdrop-filter: blur(12px);
}

.star-back:hover {
    background: rgba(15, 23, 42, 0.88);
}

.star-back[hidden] {
    display: none;
}

.chapter-qa-panel {
    display: grid;
    gap: 18px;
}

.section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.section-head p {
    margin: 6px 0 0;
    color: #64748b;
}

.chapter-qa-form {
    display: grid;
    gap: 10px;
}

.chapter-qa-form label {
    font-weight: 700;
}

.chapter-qa-form textarea {
    width: 100%;
    resize: vertical;
}

.chapter-qa-form button {
    justify-self: start;
}

.qa-history {
    display: grid;
    gap: 12px;
}

.qa-history h3 {
    margin: 0;
    font-size: 18px;
}

.qa-item {
    padding: 16px;
    border: 1px solid #dbeafe;
    border-radius: 8px;
    background: #f8fafc;
}

.qa-item h4 {
    margin: 0 0 10px;
    font-size: 16px;
}

.qa-item p {
    margin: 0;
    color: #1f2937;
}

.qa-item small {
    display: block;
    margin-top: 12px;
    color: #64748b;
}

.qa-link-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.qa-link-card {
    display: grid;
    gap: 6px;
    padding: 14px;
    border: 1px solid #dbeafe;
    border-radius: 8px;
    background: #f8fafc;
    color: #111827;
}

.qa-link-card:hover {
    border-color: #93c5fd;
    background: #eff6ff;
    text-decoration: none;
}

.qa-link-card span {
    color: #2563eb;
    font-size: 14px;
}

blockquote {
    margin: 0;
    padding: 14px;
    border-left: 4px solid #93c5fd;
    background: #f8fafc;
}

.paper {
    background: #ffffff;
    padding: 32px;
    border: 1px solid #e5e7eb;
}

.question {
    margin-top: 26px;
    break-inside: avoid;
}

.question h2 {
    font-size: 16px;
    font-weight: 600;
}

.options {
    margin-top: 8px;
}

.answer-space {
    min-height: 48px;
    border-bottom: 1px dashed #d1d5db;
    margin-top: 12px;
}

.answer {
    margin-top: 12px;
    padding: 12px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 6px;
}

@media (max-width: 760px) {
    .topbar,
    .page-head {
        flex-direction: column;
        align-items: stretch;
    }

    .upload-hero,
    .result-links {
        grid-template-columns: 1fr;
    }

    .star-map {
        min-height: 560px;
    }

    .star-node {
        max-width: 112px;
    }

    .star-node strong {
        font-size: 11px;
    }

    .two-column {
        grid-template-columns: 1fr;
    }
}

@media print {
    .topbar,
    .print-hide,
    .messages {
        display: none;
    }

    body {
        background: #ffffff;
    }

    .container,
    .paper {
        max-width: none;
        padding: 0;
        border: 0;
    }
}
