body {
    margin: 0;
    background: #f4f7f9;
    color: #003858;
}

h1:focus,
h1:focus-visible {
    outline: none;
}

.nova-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 64px;
    padding: 0 24px;
    background: #fff;
    border-bottom: 1px solid #dae3e8;
}

.nova-main {
    max-width: 920px;
    margin: 32px auto;
    padding: 0 16px;
}

.nova-main:has(> .nd) {
    max-width: none;
    margin: 0;
    padding: 0;
}

.nova-main:has(> .nova-home) {
    max-width: 1280px;
}

.nova-home {
    display: flex;
    gap: 16px;
    align-items: stretch;
    height: calc(100dvh - 64px - 64px);
    min-height: 480px;
}

.nova-home > .nova-chat {
    flex: 1;
    min-width: 0;
}

.nova-history {
    flex: 0 0 280px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px;
    background: #fff;
    border: 1px solid #dae3e8;
    border-radius: 12px;
    overflow: auto;
}

.nova-history h2 {
    margin: 0;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.nova-history ul {
    list-style: none;
    margin: 12px 0 0;
    padding: 0;
}

.nova-history li {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 4px;
    border-bottom: 1px solid #dae3e8;
}

.nova-history-search {
    width: 100%;
    box-sizing: border-box;
    margin-top: 8px;
    padding: 4px 8px;
    border: 1px solid #cfdbe2;
    border-radius: 6px;
    background: #f8fafb;
    color: #003858;
    font: inherit;
    font-size: .85rem;
}

.nova-history-search::placeholder {
    color: #8a9ca8;
    opacity: 1;
}

.nova-history-search:focus {
    background: #fff;
    outline: none;
    border-color: #1d70b7;
}

.nova-history-selected {
    background: #e5f0f5;
    border-radius: 6px;
}

.nova-history-link {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.nova-history-link strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nova-history small,
.nova-muted {
    color: #5b7385;
    font-size: .75rem;
}

.nova-history-icon,
.nova-history-confirm button {
    padding: 2px 6px;
    border: 1px solid #dae3e8;
    border-radius: 4px;
    background: none;
    color: #5b7385;
    cursor: pointer;
}

.nova-history-confirm {
    display: flex;
    gap: 4px;
}

.nova-history-confirm .nova-history-danger {
    color: #c62828;
    border-color: #c62828;
}

@media (max-width: 900px) {
    .nova-home { flex-direction: column; height: auto; }
    .nova-history { flex-basis: auto; max-height: 40vh; }
}

.nova-chat {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 0;
    box-sizing: border-box;
    padding: 24px;
    background: #fff;
    border: 1px solid #dae3e8;
    border-radius: 12px;
}

.nova-chat h1, .nova-chat p {
    margin: 0;
}

.nova-chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 16px;
    border-bottom: 1px solid #dae3e8;
}

.nova-logo {
    width: 52px;
    height: 52px;
    flex: 0 0 52px;
    color: #1d70b7;
}

.nova-logo-large {
    width: 56px;
    height: 56px;
    flex-basis: 56px;
}

.nova-chat-header h1 {
    font-size: 1.25rem;
    line-height: 1.2;
}

.nova-chat-header p {
    color: #5b7385;
    font-size: .875rem;
}

.nova-empty {
    margin: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    max-width: 420px;
    text-align: center;
}

.nova-empty h2 {
    margin: 8px 0 0;
    font-size: 1.4rem;
}

.nova-empty p {
    color: #5b7385;
}

.nova-messages {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    min-height: 0;
    padding: 12px 0;
}

.nova-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 12px;
    background: #f4f7f9;
    overflow-wrap: anywhere;
}

.nova-message-text {
    white-space: pre-wrap;
}

.nova-thinking-body {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 4px;
}

.nova-thinking-body > .element-loading-indicator {
    flex: 0 0 auto;
    color: #1d70b7;
}

/* Balls animation moves ±2.1rem horizontally (fixed in ComponentsLib) */
.nova-loading-row {
    display: flex;
    align-items: center;
}

/* The component passes the class to the outer AND the inner container, so target both explicitly. */
.nova-loading-row > .nova-loading,
.nova-thinking-body > .nova-loading {
    flex: 0 0 5.6rem;
    width: 5.6rem !important;
    height: 1rem !important;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.nova-loading > .nova-loading {
    flex: 0 0 1rem;
    width: 1rem !important;
    height: 1rem !important;
    margin: 0;
    display: block;
}

.nova-loading .element-loading-indicator-balls {
    position: relative;
    width: 1rem;
    height: 1rem;
}

.nova-loading .blob-1,
.nova-loading .blob-2 {
    width: 1rem !important;
    height: 1rem !important;
}

.nova-loading .element-loading-indicator-text:empty {
    display: none;
}

.nova-thinking-text {
    color: #003858;
}

.nova-message-user {
    align-self: flex-end;
    background: #e5f0f5;
}

.nova-message-assistant {
    align-self: flex-start;
}

.nova-markdown > :first-child { margin-top: 0; }
.nova-markdown > :last-child { margin-bottom: 0; }
.nova-markdown p,
.nova-markdown ul,
.nova-markdown ol { margin: 0.5em 0; }
.nova-markdown ul,
.nova-markdown ol { padding-left: 1.5em; }
.nova-markdown h1,
.nova-markdown h2,
.nova-markdown h3,
.nova-markdown h4 { margin: 0.8em 0 0.4em; font-size: 1.1em; }
.nova-markdown code {
    padding: 1px 4px;
    border-radius: 4px;
    background: #e3e8ec;
    font-family: Consolas, monospace;
    font-size: 0.9em;
}
.nova-markdown pre {
    padding: 10px 12px;
    border-radius: 8px;
    background: #e3e8ec;
    overflow-x: auto;
}
.nova-markdown pre code { padding: 0; background: none; }
.nova-markdown table {
    border-collapse: collapse;
    margin: 0.5em 0;
    display: block;
    overflow-x: auto;
}
.nova-markdown th,
.nova-markdown td {
    border: 1px solid #cfd8de;
    padding: 4px 8px;
    text-align: left;
}
.nova-markdown th { background: #e3e8ec; }
.nova-markdown blockquote {
    margin: 0.5em 0;
    padding-left: 12px;
    border-left: 3px solid #cfd8de;
    color: #4a5a66;
}

.nova-compose {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nova-compose textarea {
    padding: 12px;
    border: 1px solid #a8bcc8;
    border-radius: 8px;
    color: #003858;
    resize: vertical;
    font: inherit;
}

.nova-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

@media (max-width: 600px) {
    .nova-main { margin: 16px auto; }
    .nova-chat { padding: 16px; }
    .nova-message { max-width: 95%; }
}

.nova-main:has(> .nova-home-split) {
    max-width: none;
    margin: 16px;
    padding: 0;
}

.nova-home-split .nova-history {
    flex: 0 0 220px;
}

.nova-home-split > .nova-chat {
    flex: 0 1 420px;
}

.nova-document {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #dae3e8;
    border-radius: 12px;
    overflow: hidden;
}

.nova-document-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid #dae3e8;
}

.nova-document-toolbar h2 {
    margin: 0;
    font-size: 1rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nova-document-actions {
    display: flex;
    gap: 6px;
}

.nova-document-icon {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border: 1px solid #dae3e8;
    border-radius: 6px;
    background: none;
    color: #003858;
    font: inherit;
    font-size: .8rem;
    cursor: pointer;
}

.nova-document-icon svg {
    width: 20px;
    height: 20px;
}

.nova-document-icon:hover {
    background: #e5f0f5;
}

.nova-document-page {
    flex: 1;
    overflow: auto;
    padding: 24px 32px;
    background: #fff;
    color: #003858;
}

.nova-document-page h1 {
    margin: 0 0 4px;
    font-size: 1.5rem;
}

.nova-document-section {
    margin-top: 24px;
}

.nova-document-section h3 {
    margin: 0 0 8px;
    font-size: 1.1rem;
}

.nova-document-chart {
    margin: 16px 0 0;
    padding: 12px;
    border: 1px solid #dae3e8;
    border-radius: 8px;
    page-break-inside: avoid;
}

.nova-document-chart figcaption {
    margin-bottom: 8px;
    font-weight: 600;
    font-size: .9rem;
}

.nova-document-link {
    align-self: flex-start;
    margin-top: 8px;
    padding: 4px 10px;
    border: 1px solid #1d70b7;
    border-radius: 6px;
    background: #fff;
    color: #1d70b7;
    font: inherit;
    font-size: .8rem;
    cursor: pointer;
}

@media (max-width: 1100px) {
    .nova-home-split { flex-direction: column; height: auto; }
    .nova-home-split .nova-history,
    .nova-home-split > .nova-chat { flex-basis: auto; }
    .nova-document { min-height: 70vh; }
}

.nova-document-icon-active {
    background: #1d70b7;
    border-color: #1d70b7;
    color: #fff;
}

.nova-document-icon-active:hover {
    background: #175c96;
}

.nova-document-error {
    margin: 0;
    padding: 8px 16px;
    background: #fdecea;
    color: #c62828;
    font-size: .85rem;
}

.nova-editor {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.nova-editor-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: .8rem;
    color: #5b7385;
}

.nova-editor input,
.nova-editor textarea,
.nova-editor select {
    box-sizing: border-box;
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #cfdbe2;
    border-radius: 6px;
    background: #fff;
    color: #003858;
    font: inherit;
    font-size: .9rem;
}

.nova-editor textarea {
    resize: vertical;
    line-height: 1.45;
}

.nova-editor input:focus,
.nova-editor textarea:focus,
.nova-editor select:focus {
    outline: none;
    border-color: #1d70b7;
    box-shadow: 0 0 0 2px rgba(29, 112, 183, .15);
}

.nova-editor-title {
    font-size: 1.25rem !important;
    font-weight: 700;
}

.nova-editor-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    border: 1px solid #dae3e8;
    border-radius: 8px;
    background: #f8fafb;
}

.nova-editor-section-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nova-editor-section-toolbar > div,
.nova-editor-row {
    display: flex;
    gap: 6px;
}

.nova-editor button {
    padding: 4px 10px;
    border: 1px solid #cfdbe2;
    border-radius: 6px;
    background: #fff;
    color: #003858;
    font: inherit;
    font-size: .8rem;
    cursor: pointer;
}

.nova-editor button:hover:not(:disabled) {
    background: #e5f0f5;
}

.nova-editor button:disabled {
    opacity: .4;
    cursor: default;
}

.nova-editor .nova-editor-danger {
    color: #c62828;
    border-color: #f1c4c4;
}

.nova-editor .nova-editor-add {
    align-self: flex-start;
    border-style: dashed;
    border-color: #1d70b7;
    color: #1d70b7;
}

.nova-editor-chart {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0;
    padding: 10px 12px;
    border: 1px solid #dae3e8;
    border-radius: 8px;
    background: #fff;
}

.nova-editor-chart legend {
    padding: 0 4px;
    font-size: .8rem;
    font-weight: 600;
}

.nova-editor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 8px;
}

.nova-editor-data {
    width: 100%;
    border-collapse: collapse;
    font-size: .85rem;
}

.nova-editor-data th {
    padding: 4px;
    text-align: left;
    font-weight: 600;
    color: #5b7385;
}

.nova-editor-data td {
    padding: 2px 4px;
}

.nova-editor-data td:last-child {
    width: 1%;
}

.nova-message-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.nova-source-tags {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 4px;
    margin-left: auto;
}

.nova-source-tag {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.06);
    color: inherit;
    font-size: 0.72rem;
    line-height: 1.5;
    opacity: 0.8;
}
