/* Socartes · concise DeepTutor chat style · author tckr */

:root {
    --bg: #f1f2f2;
    --surface: #ffffff;
    --surface-2: #f7f9fb;
    --surface-3: #eef5fb;
    --text: #111827;
    --text-soft: #333333;
    --muted: #6d6d6d;
    --muted-2: #9aa4ad;
    --border: rgba(0, 68, 131, 0.12);
    --border-strong: rgba(0, 68, 131, 0.28);
    --accent: #004483;
    --accent-2: #7dad47;
    --green: #7dad47;
    --red: #d85014;
    --blue: #286dc0;
    --radius: 10px;
    --sans: "Plus Jakarta Sans", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --serif: Lora, Georgia, "Times New Roman", serif;
    --mono: "SF Mono", "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    background:
        linear-gradient(180deg, rgba(0, 68, 131, 0.05), transparent 260px),
        var(--bg);
    color: var(--text);
    font-family: var(--sans);
    font-size: 14px;
    line-height: 1.45;
    letter-spacing: 0;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

.page-pet {
    --pet-left: calc(100vw - 210px);
    --pet-top: calc(100vh - 270px);
    --pet-scale: 0.62;
    --pet-row: 0;
    --pet-frames: 6;
    --pet-duration: 1100ms;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 35;
    width: calc(192px * var(--pet-scale));
    height: calc(244px * var(--pet-scale));
    transform: translate3d(var(--pet-left), var(--pet-top), 0);
    pointer-events: none;
    touch-action: none;
    user-select: none;
}

.pet-body {
    position: absolute;
    left: 0;
    bottom: 0;
    width: calc(192px * var(--pet-scale));
    height: calc(208px * var(--pet-scale));
    padding: 0;
    overflow: hidden;
    background: transparent;
    cursor: grab;
    pointer-events: auto;
    filter: drop-shadow(0 15px 16px rgba(0, 42, 91, 0.22));
}

.page-pet.is-dragging .pet-body,
.pet-body:active {
    cursor: grabbing;
}

.pet-sprite {
    --sprite-y: calc(var(--pet-row) * -208px);
    --sprite-end-x: calc(var(--pet-frames) * -192px);
    display: block;
    width: 192px;
    height: 208px;
    background-image: url("assets/pets/academicasi/sprite.webp");
    background-repeat: no-repeat;
    background-size: 1536px 1872px;
    image-rendering: pixelated;
    transform: scale(var(--pet-scale));
    transform-origin: 0 0;
    animation: pet-state var(--pet-duration) steps(var(--pet-frames)) infinite;
}

.pet-bubble {
    position: absolute;
    right: 0;
    bottom: calc(100% - 14px);
    width: min(260px, calc(100vw - 32px));
    min-height: 36px;
    padding: 10px 12px;
    border: 1px solid rgba(0, 68, 131, 0.18);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 12px 34px rgba(0, 42, 91, 0.14);
    color: var(--text-soft);
    font-size: 13px;
    font-weight: 700;
    line-height: 1.35;
    text-align: left;
    transform: translateY(6px);
    opacity: 0;
    transition: opacity .18s ease, transform .18s ease;
    pointer-events: none;
}

.page-pet.near-left .pet-bubble {
    right: auto;
    left: 0;
}

.pet-bubble.is-visible {
    transform: translateY(0);
    opacity: 1;
}

.pet-bubble::after {
    content: "";
    position: absolute;
    right: 42px;
    bottom: -7px;
    width: 12px;
    height: 12px;
    border-right: 1px solid rgba(0, 68, 131, 0.18);
    border-bottom: 1px solid rgba(0, 68, 131, 0.18);
    background: rgba(255, 255, 255, 0.94);
    transform: rotate(45deg);
}

.page-pet.near-left .pet-bubble::after {
    right: auto;
    left: 42px;
}

.page-pet.is-agent-cursor .pet-body {
    cursor: pointer;
    filter: drop-shadow(0 18px 22px rgba(0, 68, 131, 0.3));
}

.page-pet.is-agent-cursor::after {
    content: "";
    position: absolute;
    left: calc(72px * var(--pet-scale));
    bottom: calc(58px * var(--pet-scale));
    width: 14px;
    height: 14px;
    border: 2px solid rgba(0, 68, 131, 0.6);
    border-radius: 999px;
    animation: pet-click-pulse .7s ease-out infinite;
    pointer-events: none;
}

.pet-agent-dialog {
    position: fixed;
    right: 22px;
    bottom: 172px;
    z-index: 38;
    width: min(360px, calc(100vw - 28px));
    border: 1px solid rgba(0, 68, 131, 0.16);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 22px 54px rgba(0, 42, 91, 0.18);
    overflow: hidden;
}

.pet-agent-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid rgba(0, 68, 131, 0.1);
}

.pet-agent-head strong {
    display: block;
    color: var(--text);
    font-size: 14px;
}

.pet-agent-head span {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
}

.pet-agent-close {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: rgba(0, 68, 131, 0.08);
    color: var(--text);
    font-size: 18px;
}

.pet-agent-log {
    display: flex;
    max-height: 230px;
    flex-direction: column;
    gap: 8px;
    padding: 12px 14px;
    overflow-y: auto;
}

.pet-agent-msg {
    max-width: 92%;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(0, 68, 131, 0.08);
    color: var(--text-soft);
    font-size: 12.5px;
    line-height: 1.35;
}

.pet-agent-msg.user {
    align-self: flex-end;
    background: #004483;
    color: #ffffff;
}

.pet-agent-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 14px 12px;
}

.pet-agent-chips button {
    min-height: 28px;
    padding: 0 9px;
    border-radius: 999px;
    background: rgba(0, 68, 131, 0.08);
    color: var(--text-soft);
    font-size: 12px;
    font-weight: 700;
}

.pet-agent-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 0 14px 12px;
    padding: 8px 10px;
    border: 1px solid rgba(0, 68, 131, 0.12);
    border-radius: 10px;
    background: rgba(0, 68, 131, 0.05);
    color: var(--text-soft);
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
}

.pet-agent-toggle input {
    width: 34px;
    height: 18px;
    accent-color: #004483;
    cursor: pointer;
}

.pet-agent-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    padding: 12px 14px 14px;
    border-top: 1px solid rgba(0, 68, 131, 0.1);
}

.pet-agent-form input {
    min-width: 0;
    height: 36px;
    padding: 0 10px;
    border: 1px solid rgba(0, 68, 131, 0.16);
    border-radius: 9px;
    background: #ffffff;
    color: var(--text);
    font: inherit;
}

.pet-agent-form button {
    min-width: 54px;
    border-radius: 9px;
    background: #004483;
    color: #ffffff;
    font-weight: 800;
}

.pet-click-target {
    outline: 3px solid rgba(0, 68, 131, 0.35);
    outline-offset: 3px;
}

@keyframes pet-click-pulse {
    from {
        opacity: .7;
        transform: scale(.7);
    }

    to {
        opacity: 0;
        transform: scale(1.8);
    }
}

@keyframes pet-state {
    from {
        background-position: 0 var(--sprite-y);
    }

    to {
        background-position: var(--sprite-end-x) var(--sprite-y);
    }
}

@media (prefers-reduced-motion: reduce) {
    .pet-sprite {
        animation: none;
    }
}

@media (max-width: 760px) {
    .pet-agent-dialog {
        right: 10px;
        bottom: 128px;
    }
}

button,
input,
select,
textarea {
    font: inherit;
    letter-spacing: 0;
}

button {
    border: 0;
    color: inherit;
    cursor: pointer;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    outline: none;
}

input,
select {
    height: 36px;
    padding: 0 11px;
}

textarea {
    min-height: 76px;
    padding: 12px 15px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--border-strong);
}

input::placeholder,
textarea::placeholder {
    color: var(--muted);
}

input[type="file"] {
    height: auto;
    min-height: 34px;
    padding: 6px;
    color: var(--muted);
}

input[type="file"]::file-selector-button {
    min-height: 24px;
    margin-right: 8px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface-2);
    color: var(--text-soft);
}

code,
pre {
    font-family: var(--mono);
}

.app-frame {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: 220px;
    display: flex;
    flex-shrink: 0;
    flex-direction: column;
    background: var(--accent);
    border-right: 1px solid rgba(255, 255, 255, 0.18);
}

.side-brand {
    display: flex;
    height: 56px;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 9px;
    color: #ffffff;
    text-decoration: none;
    font-size: 16px;
    font-weight: 700;
}

.brand-mark {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.34);
    border-radius: 999px;
    background: #ffffff;
}

.brand-mark img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.side-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 10px;
}

.side-action,
.nav-tab {
    width: 100%;
    min-height: 36px;
    padding: 0 12px;
    border-radius: 9px;
    background: transparent;
    color: rgba(255, 255, 255, 0.76);
    text-align: left;
    font-size: 13.5px;
    font-weight: 700;
}

.side-action:hover,
.nav-tab:hover,
.nav-tab.active {
    background: rgba(255, 255, 255, 0.14);
    color: #ffffff;
}

.nav-tab.active {
    font-weight: 800;
}

.nav-tab.pet-guide-target {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22), 0 0 0 3px rgba(255, 255, 255, 0.08);
}

.sidebar-fold {
    min-height: 0;
    margin: 6px 10px 10px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 9px;
    background: rgba(0, 0, 0, 0.12);
}

.nav-history-fold {
    margin: 0 0 8px;
}

.nav-exam-fold {
    margin: 0 0 8px;
}

.sidebar-fold summary {
    display: flex;
    min-height: 34px;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 0 10px;
    color: rgba(255, 255, 255, 0.74);
    cursor: pointer;
    font-size: 12px;
    list-style: none;
}

.sidebar-fold summary::-webkit-details-marker {
    display: none;
}

.sidebar-fold summary::before {
    content: "▾";
    color: rgba(255, 255, 255, 0.6);
    font-size: 10px;
}

.sidebar-fold:not([open]) summary::before {
    content: "▸";
}

.sidebar-fold summary span {
    flex: 1;
}

.sidebar-fold summary code {
    color: rgba(255, 255, 255, 0.62);
    font-size: 10px;
}

.sidebar-refresh {
    width: calc(100% - 16px);
    margin: 0 8px 8px;
}

.sidebar-history-list {
    max-height: min(42vh, 360px);
    padding: 0 8px 8px;
    overflow: auto;
}

.side-footer {
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.16);
    padding: 14px;
}

.settings-button {
    display: flex;
    width: 100%;
    min-height: 38px;
    align-items: center;
    justify-content: flex-start;
    gap: 9px;
    padding: 0 12px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 9px;
    background: rgba(0, 0, 0, 0.14);
    color: rgba(255, 255, 255, 0.84);
    font-weight: 650;
}

.settings-button:hover {
    border-color: rgba(255, 255, 255, 0.34);
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

.settings-icon {
    display: grid;
    width: 20px;
    height: 20px;
    place-items: center;
    color: var(--accent-2);
}

.backend-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    color: var(--muted);
    font-size: 13px;
}

.connection-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--muted);
}

.connection-dot.online {
    background: var(--green);
}

.connection-dot.error {
    background: var(--red);
}

.backend-control {
    display: grid;
    grid-template-columns: 1fr 34px;
    gap: 6px;
}

.backend-control input {
    height: 34px;
    font-size: 11px;
}

.backend-control button {
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface);
    color: var(--muted);
}

.runtime-cards {
    display: grid;
    gap: 7px;
    margin-top: 11px;
}

.status-card {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    color: var(--muted);
    font-size: 11px;
}

.status-card strong {
    color: var(--text-soft);
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 500;
    overflow-wrap: anywhere;
    text-align: right;
}

.version {
    display: block;
    margin-top: 13px;
    color: var(--muted);
    font-size: 11px;
}

.main-pane {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

.main-top {
    display: flex;
    height: 56px;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.main-top h1 {
    margin: 0;
    font-size: 15px;
    font-weight: 650;
}

.top-actions {
    display: flex;
    gap: 8px;
}

.ghost-btn,
.solid-btn {
    min-height: 32px;
    padding: 0 13px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: transparent;
    color: var(--muted);
}

.ghost-btn:hover,
.solid-btn:hover {
    border-color: var(--border-strong);
    color: var(--text);
}

.ghost-btn:disabled,
.solid-btn:disabled {
    cursor: default;
    opacity: 0.45;
}

.solid-btn {
    border-color: var(--accent);
    background: var(--accent);
    color: #ffffff;
}

.view {
    display: none;
    min-height: 0;
}

.view.active {
    display: block;
}

.view.active:not(.chat-view) {
    height: calc(100vh - 56px);
    overflow-x: hidden;
    overflow-y: auto;
    padding-bottom: 32px;
}

.chat-view {
    position: relative;
    flex: 1;
    height: calc(100vh - 56px);
    overflow: hidden;
}

.history-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px;
    border-bottom: 1px solid var(--border);
    color: var(--muted);
    font-size: 12px;
}

.history-list {
    flex: 1;
    min-height: 0;
    gap: 6px;
    overflow: auto;
    padding: 8px;
}

.history-row {
    display: grid;
    width: 100%;
    gap: 3px;
    padding: 9px;
    border: 1px solid transparent;
    border-radius: 9px;
    background: transparent;
    color: var(--muted);
    text-align: left;
}

.history-row:hover {
    border-color: var(--border);
    background: var(--surface-2);
    color: var(--text-soft);
}

.history-row strong {
    color: var(--text-soft);
    font-size: 12px;
    font-weight: 650;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-row small {
    color: var(--muted);
    font-family: var(--mono);
    font-size: 10px;
}

.history-row span {
    display: -webkit-box;
    overflow: hidden;
    color: var(--muted);
    font-size: 11px;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.welcome {
    position: absolute;
    top: 31%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(720px, calc(100% - 80px));
    text-align: center;
    pointer-events: none;
    transition: opacity .2s ease;
}

.welcome.hidden {
    opacity: 0;
}

.welcome h2 {
    margin: 0 0 16px;
    color: var(--accent);
    font-family: var(--serif);
    font-size: 40px;
    font-weight: 700;
    line-height: 1.15;
}

.welcome p {
    margin: 0;
    color: var(--muted);
    font-size: 15px;
}

.thread {
    height: calc(100% - 148px);
    overflow: auto;
    padding: 24px min(12vw, 180px) 120px;
    scrollbar-width: thin;
}

.message {
    width: min(780px, 100%);
    margin: 0 auto 18px;
    color: var(--text-soft);
}

.message.system {
    display: none;
}

.message.user {
    display: flex;
    justify-content: flex-end;
}

.message.user .message-body {
    max-width: min(680px, 82%);
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #eef5fb;
    color: var(--text);
}

.message.assistant .message-body {
    white-space: pre-wrap;
    color: var(--text-soft);
}

.message.assistant .message-body.has-trace {
    display: grid;
    gap: 10px;
    white-space: normal;
}

.message.assistant .message-body.has-quiz {
    white-space: normal;
}

.message-head {
    margin-bottom: 6px;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 11px;
}

.message.user .message-head {
    display: none;
}

.message-body {
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.assistant-main-content {
    display: grid;
    gap: 10px;
    max-width: min(760px, 100%);
    color: var(--text-soft);
    font-size: 15px;
    line-height: 1.72;
    white-space: normal;
}

.assistant-main-content.is-compact,
.trace-row-content.is-compact {
    gap: 5px;
    font-size: 12px;
    line-height: 1.6;
}

.assistant-main-content p,
.trace-row-content p {
    margin: 0;
}

.assistant-main-content h3,
.assistant-main-content h4,
.assistant-main-content h5,
.trace-row-content h3,
.trace-row-content h4,
.trace-row-content h5 {
    margin: 6px 0 0;
    color: var(--text);
    font-size: 17px;
    line-height: 1.35;
}

.trace-row-content h3,
.trace-row-content h4,
.trace-row-content h5 {
    font-size: 12px;
}

.assistant-main-content ul,
.assistant-main-content ol,
.trace-row-content ul,
.trace-row-content ol {
    display: grid;
    gap: 5px;
    margin: 0;
    padding-left: 22px;
}

.assistant-main-content li,
.trace-row-content li {
    padding-left: 2px;
}

.assistant-main-content strong,
.trace-row-content strong {
    color: var(--text);
    font-weight: 700;
}

.assistant-main-content code,
.trace-row-content code {
    padding: 2px 5px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--accent);
    font-family: var(--mono);
    font-size: 0.9em;
}

.assistant-main-content a,
.trace-row-content a {
    color: var(--blue);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.assistant-main-content blockquote,
.trace-row-content blockquote {
    display: grid;
    gap: 6px;
    margin: 0;
    padding: 8px 0 8px 12px;
    border-left: 3px solid var(--border-strong);
    color: var(--muted);
}

.md-code-block {
    max-width: 100%;
    margin: 0;
    overflow: auto;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--text-soft);
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.55;
    white-space: pre;
}

.md-code-block code {
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font-size: inherit;
}

.md-table-wrap {
    max-width: 100%;
    overflow-x: auto;
}

.md-table-wrap table {
    width: 100%;
    min-width: 420px;
    border-collapse: collapse;
    font-size: 13px;
}

.md-table-wrap th,
.md-table-wrap td {
    padding: 8px 9px;
    border: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

.md-table-wrap th {
    background: var(--surface-2);
    color: var(--text);
    font-weight: 700;
}

.assistant-trace-panel {
    display: grid;
    gap: 6px;
    width: min(760px, 100%);
    padding: 2px 0 8px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}

.assistant-trace-panel.reasoning-only {
    padding: 0 0 6px;
}

.assistant-trace-head {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted-2);
    font-family: var(--mono);
    font-size: 10px;
    text-transform: uppercase;
}

.assistant-trace-head strong {
    color: var(--muted);
    font-size: 10px;
    font-weight: 600;
}

.assistant-trace-head span {
    color: var(--muted-2);
}

.assistant-reasoning-text {
    display: grid;
    gap: 6px;
    max-width: min(720px, 100%);
    color: rgba(51, 51, 51, 0.68);
    font-size: 13px;
    line-height: 1.7;
}

.assistant-reasoning-text p {
    margin: 0;
}

.assistant-reasoning-text strong {
    color: rgba(51, 51, 51, 0.78);
}

.assistant-reasoning-text code {
    padding: 1px 4px;
    border: 0;
    border-radius: 5px;
    background: rgba(0, 68, 131, 0.06);
    color: var(--accent);
    font-family: var(--mono);
    font-size: 0.9em;
}

.assistant-reasoning-text ul,
.assistant-reasoning-text ol {
    display: grid;
    gap: 3px;
    margin: 0;
    padding-left: 18px;
}

.trace-group-list {
    display: grid;
    gap: 6px;
}

.trace-group {
    overflow: hidden;
    border-left: 2px solid rgba(40, 109, 192, 0.25);
    border-radius: 0 8px 8px 0;
    background: rgba(255, 255, 255, 0.42);
}

.trace-summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    min-height: 28px;
    padding: 5px 8px;
    cursor: pointer;
    list-style: none;
}

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

.trace-title {
    min-width: 0;
    color: var(--text-soft);
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.trace-title::before {
    content: "";
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-right: 7px;
    border-radius: 999px;
    background: var(--accent-2);
    box-shadow: 0 0 0 3px rgba(125, 173, 71, 0.12);
    vertical-align: 1px;
}

.trace-summary-meta {
    min-width: 0;
    max-width: 42vw;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--muted-2);
    font-family: var(--mono);
    font-size: 10px;
    white-space: nowrap;
}

.trace-body {
    display: grid;
    gap: 0;
    max-height: 280px;
    overflow: auto;
    padding: 0 10px 10px 18px;
}

.trace-row {
    display: grid;
    gap: 6px;
    padding: 9px 0 10px;
    border-top: 1px solid var(--border);
}

.trace-row:first-child {
    border-top: 0;
}

.trace-row-head {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    align-items: baseline;
}

.trace-row-label {
    min-width: 74px;
    color: var(--text-soft);
    font-size: 11px;
    font-weight: 700;
}

.trace-row-meta {
    color: var(--muted-2);
    font-family: var(--mono);
    font-size: 10px;
}

.trace-row-content {
    display: grid;
    gap: 5px;
    color: var(--muted);
    white-space: normal;
}

.trace-row.error .trace-row-content,
.trace-row.error .trace-row-label {
    color: var(--red);
}

.trace-section-label {
    margin-top: 2px;
    color: var(--muted-2);
    font-family: var(--mono);
    font-size: 10px;
    text-transform: uppercase;
}

.trace-pre {
    max-height: 190px;
    margin: 4px 0 0;
    overflow: auto;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--text-soft);
    font-family: var(--mono);
    font-size: 10px;
    line-height: 1.5;
    white-space: pre-wrap;
}

.trace-sources ul {
    display: grid;
    gap: 3px;
    margin: 4px 0 0;
    padding-left: 16px;
}

.trace-sources li {
    color: var(--muted);
    overflow-wrap: anywhere;
}

.trace-raw summary {
    width: max-content;
    cursor: pointer;
    color: var(--muted-2);
    font-family: var(--mono);
    font-size: 10px;
}

.trace-raw-bundle {
    margin-top: 0;
}

.chat-quiz-card {
    display: grid;
    gap: 14px;
    width: min(720px, 100%);
    padding: 16px;
    border: 1px solid var(--border-strong);
    border-radius: 14px;
    background: var(--surface);
}

.chat-quiz-top,
.chat-quiz-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.chat-quiz-top strong {
    color: var(--text);
    font-family: var(--mono);
    font-size: 12px;
}

.chat-quiz-steps,
.chat-quiz-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.chat-quiz-step {
    display: grid;
    width: 28px;
    height: 28px;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 12px;
}

.chat-quiz-step.active {
    border-color: var(--accent-2);
    color: var(--text);
}

.chat-quiz-meta span {
    min-height: 24px;
    padding: 3px 7px;
    border: 1px solid var(--border);
    border-radius: 7px;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 10px;
}

.chat-quiz-card h3 {
    margin: 0;
    color: var(--text);
    font-size: 17px;
    line-height: 1.55;
}

.chat-option-grid {
    display: grid;
    gap: 10px;
}

.chat-option-card {
    display: grid;
    grid-template-columns: 34px 1fr;
    gap: 10px;
    align-items: center;
    min-height: 56px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--text-soft);
    text-align: left;
}

.chat-option-card:hover {
    border-color: var(--border-strong);
    background: var(--surface-3);
}

.chat-option-card span {
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-weight: 700;
}

.chat-option-card strong {
    font-weight: 500;
    line-height: 1.45;
}

.chat-option-card.selected {
    border-color: var(--accent-2);
}

.chat-option-card.correct {
    border-color: rgba(125, 173, 71, 0.65);
}

.chat-option-card.correct span {
    background: rgba(125, 173, 71, 0.12);
    border-color: rgba(125, 173, 71, 0.65);
    color: var(--green);
}

.chat-option-card.wrong {
    border-color: rgba(216, 80, 20, 0.65);
}

.chat-option-card.wrong span {
    background: rgba(216, 80, 20, 0.12);
    border-color: rgba(216, 80, 20, 0.65);
    color: var(--red);
}

.chat-quiz-feedback {
    display: grid;
    gap: 6px;
    min-height: 42px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(0, 68, 131, 0.52);
    color: var(--muted);
}

.chat-quiz-feedback.correct {
    border-color: rgba(125, 173, 71, 0.35);
}

.chat-quiz-feedback.wrong {
    border-color: rgba(216, 80, 20, 0.35);
}

.chat-quiz-feedback strong {
    color: var(--text);
    font-size: 13px;
}

.chat-quiz-feedback.correct strong {
    color: var(--green);
}

.chat-quiz-feedback.wrong strong {
    color: var(--red);
}

.chat-quiz-feedback span {
    color: var(--text-soft);
    line-height: 1.55;
}

.activity-dock {
    position: absolute;
    left: 32px;
    bottom: 122px;
    width: 280px;
    color: var(--muted);
    font-size: 12px;
}

.activity-dock summary {
    cursor: pointer;
    text-align: left;
}

.event-list {
    max-height: 220px;
    margin-top: 8px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.96);
}

.event-item {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
}

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

.event-type {
    color: var(--text-soft);
    font-family: var(--mono);
    font-size: 10px;
}

.event-text {
    margin-top: 3px;
    color: var(--muted);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.composer {
    position: absolute;
    left: 50%;
    bottom: 20px;
    width: min(820px, calc(100% - 72px));
    transform: translateX(-50%);
    overflow: visible;
    border: 1px solid var(--border-strong);
    border-radius: 15px;
    background: var(--surface);
}

.composer.is-busy {
    border-color: rgba(0, 68, 131, 0.42);
    box-shadow: 0 10px 30px rgba(0, 68, 131, 0.12);
}

.composer textarea {
    min-height: 56px;
    max-height: 180px;
    border: 0;
    border-bottom: 1px solid var(--border);
    border-radius: 15px 15px 0 0;
    background: transparent;
    color: var(--text-soft);
    font-size: 15px;
}

.composer-toolbar {
    display: flex;
    min-height: 48px;
    align-items: center;
    gap: 7px;
    padding: 8px 58px 8px 12px;
    overflow: visible;
}

.compact-toolbar {
    min-height: 48px;
    justify-content: space-between;
    padding: 8px 58px 8px 12px;
}

.learn-course-select {
    display: grid;
    grid-template-columns: auto minmax(160px, 260px);
    gap: 8px;
    align-items: center;
    min-width: 0;
    color: var(--muted);
    font-size: 12px;
}

.learn-course-select select {
    height: 32px;
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--text-soft);
    font-size: 12px;
}

.toolbar-select {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--muted);
    font-size: 11px;
}

.toolbar-select select {
    width: auto;
    min-width: 68px;
    height: 30px;
    padding: 0 22px 0 8px;
    border: 0;
    background: transparent;
    color: var(--text-soft);
    font-size: 12px;
}

.tool-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--muted);
    font-size: 11px;
    white-space: nowrap;
}

.tool-toggle input {
    width: 13px;
    height: 13px;
    accent-color: var(--accent-2);
}

#reflectionDepth {
    width: 54px;
    height: 20px;
    padding: 0;
    border: 0;
    accent-color: var(--accent-2);
}

.tools-menu {
    position: relative;
    color: var(--muted);
    font-size: 12px;
}

.tools-menu summary {
    cursor: pointer;
    white-space: nowrap;
}

.tools-menu[open] .tool-checks {
    display: flex;
}

.tool-checks {
    position: absolute;
    left: 0;
    bottom: 30px;
    z-index: 5;
    display: none;
    width: 300px;
    max-height: 250px;
    flex-wrap: wrap;
    gap: 6px;
    overflow: auto;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
}

.tool-pill {
    display: inline-flex;
    gap: 5px;
    align-items: center;
    min-height: 27px;
    padding: 4px 7px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-soft);
    font-family: var(--mono);
    font-size: 10px;
}

.tool-pill input {
    width: 12px;
    height: 12px;
    accent-color: var(--accent-2);
}

#chatFiles {
    width: 86px;
    border: 0;
    background: transparent;
    font-size: 11px;
}

#chatFiles::file-selector-button {
    margin-right: 0;
}

#cancelBtn {
    display: none;
}

.session-chip,
.route-chip {
    color: var(--muted);
    font-size: 11px;
    white-space: nowrap;
}

.session-chip {
    display: none;
}

.route-chip {
    display: none;
}

.send-btn {
    position: absolute;
    right: 12px;
    bottom: 8px;
    width: 36px;
    height: 36px;
    margin-left: auto;
    border-radius: 50%;
    background: var(--accent);
    color: #ffffff;
    font-size: 18px;
}

.send-btn:disabled {
    cursor: wait;
    opacity: 0.82;
}

.send-btn.is-loading {
    display: grid;
    place-items: center;
}

.send-btn.is-loading::before {
    content: "";
    width: 15px;
    height: 15px;
    border: 2px solid rgba(255, 255, 255, 0.42);
    border-top-color: #ffffff;
    border-radius: 999px;
    animation: socartes-spin .8s linear infinite;
}

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

.page-head {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 12px;
    align-items: center;
    padding: 24px 32px 18px;
}

.page-head p {
    grid-column: 1 / -1;
    margin: 0;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 11px;
    text-transform: uppercase;
}

.page-head h2 {
    margin: 0;
    font-family: var(--serif);
    font-size: 32px;
}

.split,
.library-grid {
    display: grid;
    gap: 16px;
    padding: 0 32px 32px;
}

.split {
    grid-template-columns: minmax(0, 1fr) minmax(360px, 0.7fr);
}

.course-layout {
    display: grid;
    grid-template-columns: minmax(280px, 0.85fr) minmax(360px, 1fr);
    gap: 16px;
    padding: 0 32px 32px;
}

.course-list-panel,
.course-editor-panel,
.course-files-panel,
.course-preview-panel {
    min-height: 0;
}

.course-preview-panel {
    grid-row: span 2;
    display: grid;
    grid-template-rows: auto 1fr;
    min-height: calc(100vh - 160px);
}

.course-row {
    align-items: start;
}

.course-row.active {
    border-color: var(--accent-2);
}

.course-row-main {
    display: grid;
    gap: 5px;
    min-width: 0;
}

.course-name-edit {
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--text-soft);
    font-weight: 650;
    overflow: hidden;
    text-overflow: ellipsis;
}

.course-name-edit:focus {
    padding: 0 8px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: var(--surface);
}

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

.course-files-head h3,
.course-preview-head h3 {
    margin: 0;
    color: var(--text-soft);
    font-size: 14px;
}

.course-files-head strong {
    display: block;
    margin-top: 4px;
    color: var(--accent-2);
    font-family: var(--serif);
    font-size: 30px;
    line-height: 1;
}

.course-files-head code {
    max-width: 240px;
    color: var(--muted);
    font-size: 10px;
    overflow-wrap: anywhere;
    text-align: right;
}

.course-file-list {
    max-height: 360px;
    overflow: auto;
}

.course-file-row {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 11px;
    align-items: center;
    min-height: 62px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface-2);
    color: var(--text-soft);
    text-align: left;
}

.course-file-row:hover {
    border-color: var(--border-strong);
    background: var(--surface-3);
}

.course-file-icon {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border: 1px solid rgba(216, 80, 20, 0.4);
    border-radius: 8px;
    color: var(--red);
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 700;
}

.course-file-row strong {
    display: block;
    color: var(--text-soft);
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.course-file-row small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 10px;
}

.course-preview-head a {
    color: var(--accent-2);
    font-size: 12px;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.course-preview-head a.disabled {
    color: var(--muted-2);
    pointer-events: none;
}

.course-preview-empty {
    display: grid;
    min-height: 420px;
    place-items: center;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    color: var(--muted);
}

#coursePreviewFrame {
    width: 100%;
    min-height: calc(100vh - 230px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #f8fafc;
}

#coursePreviewFrame[hidden] {
    display: none;
}

.api-split {
    grid-template-columns: minmax(420px, 0.9fr) minmax(0, 1fr);
}

.library-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.books-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 16px;
}

.books-head p,
.books-head h2,
.books-head span {
    margin: 0;
}

.books-head p {
    color: var(--accent-2);
    font-family: var(--mono);
    font-size: 11px;
    text-transform: uppercase;
}

.books-head h2 {
    margin-top: 5px;
    color: var(--text);
    font-size: 26px;
    line-height: 1.2;
}

.books-head span {
    display: block;
    margin-top: 7px;
    color: var(--text-soft);
    font-size: 13px;
}

.book-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.book-stats article {
    display: grid;
    gap: 5px;
    min-height: 78px;
    align-content: center;
    padding: 13px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
}

.book-stats small {
    color: var(--muted);
    font-family: var(--mono);
    font-size: 10px;
}

.book-stats strong {
    color: var(--text);
    font-size: 24px;
    line-height: 1;
}

.book-only-layout {
    display: grid;
    grid-template-columns: minmax(310px, 0.52fr) minmax(0, 1.48fr);
    gap: 14px;
    align-items: start;
}

.book-library-panel {
    display: grid;
    gap: 11px;
    min-height: calc(100vh - 244px);
}

.book-library-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
}

.book-library-count {
    color: var(--muted);
    font-family: var(--mono);
    font-size: 11px;
    line-height: 1.35;
    text-transform: uppercase;
    white-space: pre-line;
}

.book-only-layout .book-reader-panel {
    grid-column: auto;
    grid-row: auto;
    min-height: calc(100vh - 244px);
}

#view-library:not(.book-reading) .book-reader-panel {
    display: none;
}

#view-library.book-reading .book-library-home {
    display: none;
}

#view-library.book-reading .book-only-layout {
    grid-template-columns: minmax(0, 1fr);
}

#view-library.book-reading .book-reader-panel {
    display: block;
    min-height: calc(100vh - 96px);
}

.notes-grid {
    grid-template-columns: minmax(340px, 0.76fr) minmax(0, 1.24fr);
    align-items: start;
}

.notes-primary,
.book-builder-panel,
.book-reader-panel {
    min-height: 0;
}

.notes-primary {
    grid-column: 1;
}

.book-builder-panel {
    display: grid;
    gap: 12px;
    grid-column: 1;
}

.book-reader-panel {
    grid-column: 2;
    grid-row: 1 / span 3;
    min-height: calc(100vh - 148px);
}

.notes-small-panel {
    min-height: 180px;
}

.danger-btn:hover {
    border-color: rgba(216, 80, 20, 0.42);
    color: var(--red);
}

.course-notes-panel {
    display: grid;
    gap: 12px;
}

.course-notes-log {
    min-height: 110px;
    max-height: 190px;
}

.course-notes-output {
    display: grid;
    gap: 10px;
    max-height: 420px;
    overflow: auto;
}

.course-note-card {
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface-2);
}

.course-note-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.course-note-head strong {
    color: var(--text-soft);
    font-size: 13px;
    overflow-wrap: anywhere;
}

.course-note-status {
    flex-shrink: 0;
    color: var(--accent-2);
    font-family: var(--mono);
    font-size: 10px;
}

.course-note-body {
    max-height: 260px;
    overflow: auto;
    margin: 0;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fafc;
    color: var(--text-soft);
    font-family: var(--sans);
    font-size: 12px;
    line-height: 1.6;
    white-space: pre-wrap;
}

.book-list {
    max-height: none;
    overflow: auto;
}

.book-row {
    align-items: flex-start;
}

.book-row p {
    margin: 5px 0 7px;
    color: var(--text-soft);
    font-size: 12px;
    line-height: 1.55;
}

.book-row.active,
.book-page-row.active {
    border-color: var(--accent-2);
    background: var(--surface-3);
}

.book-reader-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.book-reader-head p {
    margin: 0 0 5px;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 10px;
    overflow-wrap: anywhere;
}

.book-reader-head h3 {
    margin: 0;
    color: var(--text);
    font-size: 18px;
    line-height: 1.35;
}

.book-actions {
    justify-content: flex-end;
}

.book-detail-empty {
    display: grid;
    min-height: 420px;
    place-items: center;
    padding: 22px;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    color: var(--muted);
    text-align: center;
}

.book-detail {
    display: grid;
    gap: 14px;
}

.book-meta {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.book-meta span,
.book-proposal,
.book-block,
.book-page-tools {
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface-2);
}

.book-meta span {
    display: grid;
    gap: 4px;
    padding: 10px;
    min-width: 0;
}

.book-meta small {
    color: var(--muted);
    font-family: var(--mono);
    font-size: 10px;
}

.book-meta strong {
    color: var(--text-soft);
    font-size: 12px;
    overflow-wrap: anywhere;
}

.book-proposal {
    display: grid;
    gap: 10px;
    padding: 13px;
}

.book-proposal h4 {
    margin: 0;
    color: var(--text);
    font-size: 16px;
}

.book-proposal p {
    margin: 0;
    color: var(--text-soft);
    line-height: 1.6;
}

.proposal-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.proposal-grid div {
    display: grid;
    gap: 4px;
    padding: 9px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(0, 68, 131, 0.34);
}

.proposal-grid strong {
    color: var(--accent-2);
    font-family: var(--mono);
    font-size: 10px;
}

.proposal-grid span {
    color: var(--text-soft);
    font-size: 12px;
    line-height: 1.55;
    overflow-wrap: anywhere;
}

.book-workspace {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 12px;
    min-height: 620px;
}

.book-spine {
    display: grid;
    align-content: start;
    gap: 8px;
    max-height: 620px;
    overflow: auto;
}

.book-page-row {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 5px 9px;
    align-items: center;
    width: 100%;
    min-height: 56px;
    padding: 9px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface-2);
    color: var(--text-soft);
    text-align: left;
}

.book-page-row span {
    grid-row: 1 / span 2;
    display: grid;
    width: 28px;
    height: 28px;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 10px;
}

.book-page-row strong {
    min-width: 0;
    color: var(--text-soft);
    font-size: 12px;
    overflow-wrap: anywhere;
}

.book-page-row small {
    color: var(--muted);
    font-family: var(--mono);
    font-size: 10px;
}

.book-page {
    display: grid;
    align-content: start;
    gap: 12px;
    min-width: 0;
    max-height: 620px;
    overflow: auto;
    padding-right: 4px;
}

.book-page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.book-page-head h4 {
    margin: 0;
    color: var(--text);
    font-size: 20px;
    line-height: 1.35;
}

.book-page-head code {
    color: var(--accent-2);
    font-size: 10px;
}

.book-objectives {
    display: grid;
    gap: 6px;
    margin: 0;
    padding-left: 18px;
    color: var(--text-soft);
}

.book-page-tools {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    align-items: center;
    padding: 10px;
}

.book-page-tools span {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.book-page-tools small {
    color: var(--muted);
    font-family: var(--mono);
    font-size: 10px;
}

.book-page-tools strong {
    color: var(--text-soft);
    font-size: 11px;
    overflow-wrap: anywhere;
}

.book-block {
    display: grid;
    gap: 11px;
    padding: 13px;
}

.book-block[data-status="error"] {
    border-color: rgba(216, 80, 20, 0.45);
}

.book-block-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: start;
}

.book-block-head strong {
    color: var(--text);
    font-size: 14px;
}

.book-block-head code {
    justify-self: start;
    color: var(--muted);
    font-size: 10px;
}

.book-block-head .row-actions {
    grid-column: 1 / -1;
}

.book-block-type {
    width: 138px;
    height: 28px;
    border-radius: 8px;
    color: var(--muted);
    font-size: 12px;
}

.book-markdown {
    display: grid;
    gap: 8px;
    color: var(--text-soft);
}

.book-markdown h5,
.book-markdown p,
.book-markdown li {
    margin: 0;
    line-height: 1.7;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.book-markdown h5 {
    color: var(--text);
    font-size: 15px;
}

.book-markdown ul {
    display: grid;
    gap: 7px;
    margin: 0;
    padding-left: 20px;
}

.book-markdown strong {
    color: var(--text);
    font-weight: 700;
}

.book-markdown code {
    padding: 1px 4px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: rgba(0, 68, 131, 0.06);
    color: var(--text-soft);
    font-family: var(--mono);
    font-size: 0.92em;
}

.book-markdown mjx-container,
.book-quiz-block mjx-container,
.book-flashcards mjx-container {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    overflow-wrap: normal;
    white-space: normal;
    color: var(--text);
}

.book-markdown mjx-container *,
.book-quiz-block mjx-container *,
.book-flashcards mjx-container * {
    overflow-wrap: normal;
    white-space: normal;
}

.book-markdown mjx-container[display="true"],
.book-quiz-block mjx-container[display="true"],
.book-flashcards mjx-container[display="true"] {
    display: block;
    padding: 6px 0;
}

.book-interactive {
    display: grid;
    gap: 10px;
}

.book-interactive-description,
.book-interactive-bridge {
    margin: 0;
    color: var(--text-soft);
    font-size: 12px;
    line-height: 1.55;
}

.book-interactive-frame {
    width: 100%;
    min-height: 640px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f6f8fb;
}

.book-code,
.book-open-questions pre,
.book-block-error {
    max-height: 360px;
    overflow: auto;
    margin: 0;
    padding: 11px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fafc;
    color: var(--text-soft);
    font-size: 11px;
    line-height: 1.55;
    white-space: pre-wrap;
}

.book-concept,
.book-quiz-block {
    display: grid;
    gap: 10px;
}

.book-chapter-index {
    display: grid;
    gap: 8px;
}

.book-index-card {
    display: grid;
    gap: 5px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(0, 68, 131, 0.34);
    color: var(--text-soft);
    text-align: left;
}

.book-index-card:hover {
    border-color: var(--border-strong);
}

.book-index-card strong {
    color: var(--text);
}

.book-index-card span {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}

.book-flashcards {
    display: grid;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.72);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.16);
}

.book-flashcards-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.book-flashcards-head strong {
    color: var(--accent-2);
}

.book-flashcard {
    display: flex;
    min-height: 160px;
    width: 100%;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 18px 24px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(0, 68, 131, 0.58);
    text-align: center;
    transition: border-color 0.16s ease, background 0.16s ease;
}

.book-flashcard:hover {
    border-color: var(--border-strong);
    background: rgba(0, 68, 131, 0.76);
}

.book-flashcard small {
    color: var(--muted);
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.book-flashcard-body {
    color: var(--text);
    font-size: 16px;
    font-weight: 650;
    line-height: 1.6;
}

.book-flashcard em {
    color: var(--muted);
    font-size: 12px;
    font-style: normal;
    line-height: 1.55;
}

.book-flashcard-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.book-quiz-label {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--accent-2);
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.book-quiz-label::before,
.book-quiz-label::after {
    content: "";
    height: 1px;
    flex: 1;
    background: rgba(125, 173, 71, 0.24);
}

.book-quiz-list {
    display: grid;
    gap: 12px;
}

.book-quiz-empty {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.book-quiz-question {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(0, 68, 131, 0.54);
}

.book-quiz-question-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.book-quiz-prompt {
    display: flex;
    min-width: 0;
    flex: 1;
    align-items: flex-start;
    gap: 9px;
}

.book-quiz-number {
    padding-top: 2px;
    color: var(--text);
    font-size: 14px;
    font-weight: 650;
    line-height: 1.6;
}

.book-quiz-prompt-text,
.book-quiz-open-note {
    margin: 0;
    color: var(--text);
    font-size: 15px;
    font-weight: 650;
    line-height: 1.65;
    white-space: pre-wrap;
}

.book-quiz-open-note {
    margin-top: 9px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 400;
}

.book-quiz-prompt-text strong {
    color: var(--text);
    font-weight: 700;
}

.book-quiz-badge {
    flex-shrink: 0;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(0, 68, 131, 0.08);
    color: var(--muted);
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.book-quiz-options {
    display: grid;
    gap: 6px;
    margin-top: 12px;
}

.book-quiz-option {
    display: flex;
    width: 100%;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.7);
    color: var(--text-soft);
    text-align: left;
    font-size: 14px;
    line-height: 1.6;
    transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.book-quiz-option:hover,
.book-quiz-option.selected {
    border-color: rgba(125, 173, 71, 0.55);
    background: rgba(125, 173, 71, 0.09);
    color: var(--text);
}

.book-quiz-option.correct {
    border-color: rgba(125, 173, 71, 0.6);
    background: rgba(125, 173, 71, 0.1);
    color: var(--text);
}

.book-quiz-option.wrong {
    border-color: rgba(216, 80, 20, 0.6);
    background: rgba(216, 80, 20, 0.1);
    color: var(--text);
}

.book-quiz-option-letter {
    flex-shrink: 0;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.book-quiz-option-text {
    min-width: 0;
    flex: 1;
    white-space: pre-wrap;
}

.book-quiz-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 12px;
}

.book-quiz-reveal {
    display: inline-flex;
    min-height: 28px;
    align-items: center;
    gap: 6px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.76);
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
}

.book-quiz-reveal:hover {
    border-color: rgba(125, 173, 71, 0.55);
    color: var(--accent-2);
}

.book-quiz-answer-inline {
    color: var(--muted);
    font-size: 12px;
}

.book-quiz-answer-inline span {
    color: var(--text);
    font-family: var(--mono);
}

.book-quiz-answer-panels[hidden],
.book-quiz-answer-inline[hidden] {
    display: none;
}

.book-quiz-answer-panels {
    display: grid;
    gap: 8px;
    margin-top: 8px;
}

.book-quiz-answer-body {
    display: grid;
    gap: 10px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.7);
    color: var(--text-soft);
}

.book-quiz-explanation {
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(0, 68, 131, 0.05);
    color: var(--text-soft);
}

.book-quiz-answer-label {
    color: var(--muted);
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.book-quiz-answer-body p,
.book-quiz-explanation p {
    margin: 0;
    line-height: 1.65;
}

.book-log {
    max-height: 180px;
}

.book-diagnostics {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
}

.book-diagnostics summary {
    min-height: 36px;
    padding: 9px 12px;
    color: var(--muted);
    cursor: pointer;
    font-family: var(--mono);
    font-size: 11px;
}

.book-diagnostics .book-log {
    margin: 0 12px 12px;
}

.book-rebuild-row {
    justify-content: flex-end;
}

#view-library {
    padding: 0 24px 32px;
}

.book-head-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.book-head-actions input {
    width: 224px;
    height: 32px;
    border-radius: 6px;
    background: #f4f8fb;
    color: var(--text);
}

.book-new-btn {
    border-color: rgba(0, 68, 131, 0.82);
    background: #004483;
    color: #f8fafc;
}

#view-library .book-stats {
    gap: 12px;
    margin-bottom: 24px;
}

#view-library .book-stats article {
    min-height: 74px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.78);
}

#view-library .book-stats small {
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.book-library-panel.panel {
    min-height: 0;
    padding: 0;
    border: 0;
    background: transparent;
}

.book-library-count {
    text-transform: lowercase;
}

.book-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 380px));
    gap: 16px;
    overflow: visible;
}

.book-card {
    display: flex;
    min-height: 256px;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.72);
    cursor: pointer;
    transition: border-color 160ms ease, transform 160ms ease, background 160ms ease;
}

.book-card:hover,
.book-card.active {
    transform: translateY(-2px);
    border-color: rgba(0, 68, 131, 0.58);
}

.book-card-cover {
    position: relative;
    height: 112px;
    overflow: hidden;
    background:
        radial-gradient(circle at 18% 18%, rgba(255, 244, 221, 0.92), transparent 34%),
        linear-gradient(135deg, #eaf3fb 0%, #cde4f7 100%);
}

.book-card-cover::before {
    content: "";
    position: absolute;
    left: 14px;
    top: 18px;
    width: 1px;
    height: 82px;
    background: rgba(0, 68, 131, 0.26);
}

.book-card-status {
    position: absolute;
    left: 18px;
    top: 13px;
    display: inline-flex;
    align-items: center;
    min-height: 18px;
    padding: 0 8px;
    border-radius: 999px;
    background: rgba(125, 173, 71, 0.16);
    color: #7dad47;
    font-family: var(--mono);
    font-size: 10px;
    text-transform: uppercase;
}

.book-card-status::before {
    content: "";
    width: 5px;
    height: 5px;
    margin-right: 5px;
    border-radius: 999px;
    background: currentColor;
}

.book-card-icon {
    position: absolute;
    right: 14px;
    bottom: 14px;
    width: 28px;
    height: 28px;
    overflow: hidden;
    border: 1px solid rgba(0, 68, 131, 0.2);
    border-radius: 999px;
    background: #ffffff;
    box-shadow: 0 6px 18px rgba(0, 68, 131, 0.16);
}

.book-card-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.book-card-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 8px;
    padding: 16px;
}

.book-card-body strong {
    color: var(--text);
    font-size: 15px;
}

.book-card-body p {
    margin: 0;
    color: var(--text-soft);
    font-size: 12px;
    line-height: 1.55;
}

.book-card-meta {
    margin-top: auto;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 10px;
}

#view-library.book-reading {
    padding: 0;
}

#view-library.book-reading .book-reader-panel.panel {
    min-height: calc(100vh - 56px);
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
}

#view-library.book-reading .book-reader-head {
    min-height: 82px;
    align-items: center;
    margin: 0;
    padding: 16px 28px;
    border-bottom: 1px solid var(--border);
}

#view-library.book-reading .book-reader-head p {
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
}

#view-library.book-reading .book-reader-head h3 {
    font-size: 16px;
}

.book-reader-notice {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 16px 24px 0;
    padding: 13px 16px;
    border: 1px solid rgba(125, 173, 71, 0.5);
    border-radius: 10px;
    background: rgba(125, 173, 71, 0.42);
    color: #004483;
    font-size: 13px;
}

#view-library.book-reading .book-detail {
    gap: 0;
}

#view-library.book-reading .book-workspace {
    grid-template-columns: 232px minmax(0, 1fr);
    gap: 0;
    min-height: calc(100vh - 138px);
}

#view-library.book-reading .book-spine {
    max-height: none;
    overflow: auto;
    padding: 18px 12px;
    border-right: 1px solid var(--border);
}

.book-spine-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    padding: 0 4px;
}

.book-spine-head small {
    color: var(--muted);
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.12em;
}

.book-spine-head span {
    color: var(--muted-2);
    font-family: var(--mono);
    font-size: 10px;
}

#view-library.book-reading .book-page-row {
    min-height: 42px;
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 8px 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
}

#view-library.book-reading .book-page-row.active,
#view-library.book-reading .book-page-row:hover {
    background: rgba(0, 68, 131, 0.06);
}

#view-library.book-reading .book-page-row span {
    display: none;
}

#view-library.book-reading .book-page-row strong {
    font-size: 12px;
}

#view-library.book-reading .book-page-row small {
    align-self: center;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(0, 68, 131, 0.08);
    text-transform: uppercase;
}

#view-library.book-reading .book-page {
    position: relative;
    max-height: none;
    overflow: visible;
    gap: 22px;
    padding: 26px 284px 64px 32px;
}

#view-library.book-reading .book-page-head {
    padding-bottom: 18px;
}

#view-library.book-reading .book-page-head h4 {
    font-size: 28px;
    line-height: 1.2;
}

.book-page-head-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

#view-library.book-reading .book-page-head code {
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(0, 68, 131, 0.08);
    color: var(--text-soft);
    text-transform: uppercase;
}

#view-library.book-reading .book-objectives {
    color: var(--text-soft);
    font-size: 14px;
    line-height: 1.7;
}

#view-library.book-reading .book-block {
    gap: 14px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
}

#view-library.book-reading .book-block-section .book-block-head {
    display: none;
}

#view-library.book-reading .book-block-head {
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
}

#view-library.book-reading .book-block-head strong {
    font-size: 15px;
}

#view-library.book-reading .book-markdown {
    gap: 14px;
    color: #333333;
    font-size: 15px;
    line-height: 1.9;
}

#view-library.book-reading .book-markdown h5 {
    margin-top: 10px;
    font-size: 22px;
}

.book-callout {
    display: grid;
    gap: 8px;
    padding: 14px;
    border-left: 3px solid var(--accent-2);
    border-radius: 8px;
    background: rgba(125, 173, 71, 0.1);
}

.book-callout p,
.book-callout small {
    margin: 0;
    color: var(--text-soft);
    line-height: 1.65;
}

.book-page-toc {
    position: fixed;
    right: 18px;
    top: 386px;
    z-index: 3;
    display: grid;
    width: 220px;
    gap: 2px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.84);
    box-shadow: 0 16px 46px rgba(0, 0, 0, 0.32);
    backdrop-filter: blur(10px);
}

.book-page-toc strong {
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 11px;
    letter-spacing: 0.08em;
}

.book-page-toc button {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr) 6px;
    gap: 6px;
    align-items: center;
    min-height: 26px;
    padding: 0;
    background: transparent;
    color: var(--muted);
    text-align: left;
}

.book-page-toc em {
    overflow: hidden;
    font-style: normal;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.book-page-toc i {
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: #7dad47;
}

@media (max-width: 1100px) {
    #view-library.book-reading .book-page {
        padding-right: 32px;
    }

    .book-page-toc {
        display: none;
    }
}

.exam-layout {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    gap: 16px;
    padding: 0 32px 32px;
}

.exam-config {
    align-self: start;
}

.exam-log {
    min-height: 190px;
    max-height: 260px;
}

.exam-stage {
    min-height: calc(100vh - 160px);
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.55);
    padding: 24px;
}

.exam-empty {
    max-width: 620px;
    text-align: center;
    color: var(--muted);
}

.exam-empty h3 {
    margin: 0 0 12px;
    color: rgba(0, 68, 131, 0.62);
    font-family: var(--serif);
    font-size: 34px;
}

.exam-empty p {
    margin: 0;
}

.exam-card {
    width: min(880px, 100%);
    padding: 24px;
    border: 1px solid var(--border-strong);
    border-radius: 18px;
    background: var(--surface);
}

.exam-progress,
.exam-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.exam-progress {
    color: var(--muted);
    font-family: var(--mono);
    font-size: 12px;
}

.exam-card h3 {
    margin: 22px 0;
    color: var(--text);
    font-size: 22px;
    line-height: 1.5;
}

.option-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.option-card {
    display: grid;
    grid-template-columns: 42px 1fr auto;
    gap: 12px;
    align-items: center;
    min-height: 92px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-2);
    color: var(--text-soft);
    text-align: left;
}

.option-card:hover {
    border-color: var(--border-strong);
    background: var(--surface-3);
}

.option-label {
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-weight: 700;
}

.option-text {
    font-weight: 500;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.option-state {
    color: var(--muted);
    font-size: 11px;
    font-style: normal;
}

.option-card.selected {
    border-color: var(--accent-2);
}

.option-card.correct {
    border-color: rgba(125, 173, 71, 0.65);
}

.option-card.correct .option-label {
    background: rgba(125, 173, 71, 0.12);
    border-color: rgba(125, 173, 71, 0.65);
    color: var(--green);
}

.option-card.wrong {
    border-color: rgba(216, 80, 20, 0.65);
}

.option-card.wrong .option-label {
    background: rgba(216, 80, 20, 0.12);
    border-color: rgba(216, 80, 20, 0.65);
    color: var(--red);
}

.exam-feedback {
    display: grid;
    gap: 6px;
    min-height: 54px;
    margin: 16px 0;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--muted);
    background: var(--surface-2);
}

.exam-feedback.correct {
    color: var(--green);
    border-color: rgba(125, 173, 71, 0.35);
    background: rgba(125, 173, 71, 0.08);
}

.exam-feedback strong {
    font-size: 13px;
}

.exam-feedback span {
    color: var(--text-soft);
    line-height: 1.55;
    white-space: pre-wrap;
}

.exam-feedback.wrong {
    color: var(--red);
    border-color: rgba(216, 80, 20, 0.35);
    background: rgba(216, 80, 20, 0.08);
}

.exam-feedback.pending {
    color: var(--accent);
    border-color: rgba(40, 109, 192, 0.35);
    background: rgba(40, 109, 192, 0.08);
}

.exam-result {
    width: min(880px, 100%);
    margin-top: 14px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-2);
    text-align: center;
}

.exam-result h3 {
    margin: 0 0 6px;
    color: var(--text);
    font-size: 22px;
}

.exam-result p {
    margin: 0;
    color: var(--accent-2);
    font-family: var(--serif);
    font-size: 42px;
    font-weight: 700;
}

.memory-layout {
    display: grid;
    grid-template-columns: minmax(0, 880px);
    gap: 16px;
    padding: 0 32px 32px;
}

.memory-panel {
    min-height: calc(100vh - 148px);
}

.memory-summary-panel {
    align-self: start;
    min-height: 0;
}

.memory-summary {
    display: grid;
    gap: 14px;
}

.memory-section {
    display: grid;
    gap: 10px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface-2);
}

.memory-section h3 {
    margin: 0;
    color: var(--accent-2);
    font-family: var(--mono);
    font-size: 12px;
}

.memory-section ul {
    display: grid;
    gap: 9px;
    margin: 0;
    padding-left: 18px;
}

.memory-section li,
.memory-empty-line {
    margin: 0;
    color: var(--text-soft);
    font-size: 14px;
    line-height: 1.6;
    overflow-wrap: anywhere;
}

.memory-empty-line {
    color: var(--muted);
}

.panel {
    min-height: 120px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.panel h3,
.mini-title {
    margin: 0 0 12px;
    color: var(--text-soft);
    font-size: 14px;
}

.list {
    display: grid;
    gap: 8px;
}

.list-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    min-height: 48px;
    padding: 10px 11px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface-2);
}

.list-row.clickable {
    cursor: pointer;
}

.list-row:hover {
    border-color: var(--border-strong);
}

.list-row strong {
    display: block;
    color: var(--text-soft);
    font-size: 13px;
    overflow-wrap: anywhere;
}

.list-row small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 10px;
    overflow-wrap: anywhere;
}

.row-actions,
.button-row,
.inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.mini-btn {
    min-height: 28px;
    padding: 0 9px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    font-size: 12px;
}

.mini-btn:hover {
    color: var(--text);
    border-color: var(--border-strong);
}

.mini-btn:disabled,
.mini-btn:disabled:hover {
    color: var(--muted-2);
    border-color: var(--border);
    cursor: not-allowed;
    opacity: 0.45;
}

.mini-btn.danger:hover {
    color: var(--red);
}

.empty {
    padding: 14px;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    color: var(--muted);
}

.field-line {
    display: grid;
    grid-template-columns: 86px 1fr;
    gap: 10px;
    align-items: center;
    margin-bottom: 11px;
}

.field-line.stack {
    grid-template-columns: 1fr;
}

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

.form-stack {
    display: grid;
    gap: 10px;
    margin: 12px 0;
}

.field {
    display: grid;
    gap: 6px;
}

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

.muted-code {
    display: block;
    max-height: 48px;
    margin-bottom: 12px;
    overflow: hidden;
    color: var(--muted);
    font-size: 10px;
}

.output {
    min-height: 150px;
    max-height: 360px;
    overflow: auto;
    margin: 12px 0 0;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #f8fafc;
    color: #0f2547;
    font-size: 12px;
    white-space: pre-wrap;
}

.output.tall {
    min-height: 430px;
}

.compact-list {
    max-height: 230px;
    overflow: auto;
}

.endpoint-list {
    display: grid;
    gap: 7px;
    max-height: calc(100vh - 180px);
    margin-top: 12px;
    overflow: auto;
}

.endpoint-item {
    display: grid;
    grid-template-columns: 58px 1fr;
    gap: 10px;
    align-items: start;
    padding: 9px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface-2);
    color: var(--text-soft);
    text-align: left;
}

.endpoint-item:hover {
    border-color: var(--border-strong);
}

.method {
    display: inline-grid;
    min-height: 24px;
    place-items: center;
    border-radius: 7px;
    background: var(--surface-3);
    color: var(--text-soft);
    font-family: var(--mono);
    font-size: 10px;
}

.method.get { color: var(--green); }
.method.post { color: var(--blue); }
.method.put,
.method.patch { color: var(--accent-2); }
.method.delete { color: var(--red); }

.endpoint-path {
    display: block;
    margin-bottom: 3px;
    font-family: var(--mono);
    font-size: 12px;
    overflow-wrap: anywhere;
}

.endpoint-summary {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.method-path {
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 8px;
    margin: 12px 0;
}

.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 50;
    max-width: min(420px, calc(100vw - 36px));
    padding: 11px 13px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--text-soft);
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity .16s ease, transform .16s ease;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.settings-overlay {
    position: fixed;
    inset: 0;
    z-index: 45;
    display: flex;
    align-items: stretch;
    justify-content: flex-start;
}

.settings-overlay[hidden] {
    display: none;
}

.settings-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(5, 5, 5, 0.46);
}

.settings-panel {
    position: relative;
    z-index: 1;
    width: min(430px, calc(100vw - 28px));
    height: calc(100vh - 28px);
    margin: 14px;
    overflow: auto;
    border: 1px solid var(--border-strong);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 24px 90px rgba(0, 0, 0, 0.36);
    scrollbar-color: var(--muted-2) transparent;
    scrollbar-width: thin;
}

.settings-panel::-webkit-scrollbar {
    width: 8px;
}

.settings-panel::-webkit-scrollbar-track {
    background: transparent;
}

.settings-panel::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: var(--muted-2);
}

.settings-head {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 18px 14px;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.98);
}

.settings-head p,
.settings-section h3 {
    margin: 0;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 11px;
    text-transform: uppercase;
}

.settings-head h2 {
    margin: 2px 0 0;
    color: var(--text);
    font-size: 20px;
}

.settings-close {
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: transparent;
    color: var(--muted);
    font-size: 20px;
}

.settings-close:hover {
    border-color: var(--border-strong);
    color: var(--text);
}

.settings-section {
    display: grid;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
}

.settings-section:last-child {
    border-bottom: 0;
}

.settings-field {
    display: grid;
    gap: 7px;
}

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

.settings-toggle-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.settings-toggle-grid .tool-toggle {
    min-height: 34px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface-2);
}

.settings-panel #reflectionDepth {
    width: 100%;
}

.settings-panel #chatFiles {
    width: 100%;
    border: 1px solid var(--border);
    background: var(--surface);
}

.settings-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.settings-panel .session-chip,
.settings-panel .route-chip {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
}

.settings-panel #cancelBtn {
    display: inline-flex;
    width: 100%;
    justify-content: center;
}

.settings-panel .tools-menu {
    width: 100%;
}

.settings-panel .tools-menu[open] .tool-checks {
    position: static;
    display: flex;
    width: 100%;
    max-height: 220px;
    margin-top: 10px;
}

.settings-nav {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.settings-nav .ghost-btn {
    width: 100%;
}

@media (max-width: 1120px) {
    .sidebar {
        width: 190px;
    }

    .composer-toolbar {
        flex-wrap: wrap;
    }

    .split,
    .api-split,
    .course-layout,
    .library-grid,
    .book-only-layout,
    .exam-layout,
    .memory-layout {
        grid-template-columns: 1fr;
    }

    .book-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .course-preview-panel {
        grid-row: auto;
    }

    .book-reader-panel,
    .notes-primary,
    .book-builder-panel {
        grid-column: auto;
        grid-row: auto;
    }

    .book-workspace {
        grid-template-columns: 1fr;
    }

    .book-spine,
    .book-page {
        max-height: none;
    }

    .exam-stage {
        min-height: 520px;
    }
}

@media (max-width: 760px) {
    body {
        overflow: auto;
        overflow-x: hidden;
    }

    .page-pet {
        --pet-scale: 0.48;
        z-index: 22;
    }

    .pet-bubble {
        width: min(220px, calc(100vw - 20px));
        font-size: 12px;
    }

    .app-frame {
        width: 100%;
        max-width: 100%;
        min-height: 100vh;
        height: auto;
        flex-direction: column;
        overflow: visible;
    }

    .sidebar {
        width: 100%;
        max-width: 100%;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .side-nav {
        flex-direction: row;
        overflow: auto;
    }

    .sidebar-fold {
        flex: 0 0 auto;
        min-width: 112px;
        margin: 0 0 8px;
    }

    .sidebar-fold[open] {
        min-width: min(320px, calc(100vw - 24px));
    }

    .sidebar-fold summary {
        white-space: nowrap;
    }

    .sidebar-fold summary span,
    .sidebar-fold summary code {
        white-space: nowrap;
    }

    .sidebar-history-list {
        max-height: 210px;
    }

    .side-action,
    .nav-tab {
        width: auto;
        white-space: nowrap;
    }

    .side-footer {
        padding: 8px 12px 12px;
    }

    .settings-button {
        min-height: 34px;
    }

    .main-pane {
        width: 100%;
        max-width: 100%;
        min-height: 720px;
    }

    .view.active:not(.chat-view) {
        height: auto;
        overflow: visible;
        padding-bottom: 24px;
    }

    .main-top {
        padding: 0 16px;
    }

    .top-actions {
        display: none;
    }

    .welcome h2 {
        font-size: 30px;
    }

    .welcome {
        left: 50%;
        width: min(720px, calc(100% - 40px));
    }

    .thread {
        padding-left: 16px;
        padding-right: 16px;
    }

    .composer {
        position: fixed;
        left: 50%;
        width: calc(100% - 24px);
        bottom: 12px;
        z-index: 20;
    }

    .learn-course-select {
        grid-template-columns: 1fr;
        gap: 4px;
        width: calc(100% - 8px);
    }

    .compact-toolbar {
        justify-content: flex-start;
        padding-right: 58px;
    }

    .activity-dock {
        display: none;
    }

    .exam-layout,
    .split,
    .course-layout,
    .library-grid,
    .book-only-layout,
    .memory-layout {
        padding-left: 12px;
        padding-right: 12px;
    }

    .books-head {
        flex-direction: column;
        padding-left: 12px;
        padding-right: 12px;
    }

    .book-stats {
        grid-template-columns: 1fr;
        padding-left: 12px;
        padding-right: 12px;
    }

    .books-head h2 {
        overflow-wrap: anywhere;
        font-size: 24px;
    }

    .option-grid {
        grid-template-columns: 1fr;
    }

    .option-card {
        grid-template-columns: 42px 1fr;
    }

    .option-state {
        grid-column: 2;
    }

    .book-reader-head,
    .book-page-head {
        align-items: stretch;
        flex-direction: column;
    }

    .book-meta,
    .proposal-grid,
    .book-flashcards {
        grid-template-columns: 1fr;
    }

    .book-page-tools {
        grid-template-columns: 1fr;
    }

    .book-interactive-frame {
        min-height: 720px;
    }

    .settings-panel {
        width: calc(100vw - 20px);
        height: calc(100vh - 20px);
        margin: 10px;
    }
}
