:root {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #203239;
    background: #f3f6f5;
    line-height: 1.6;
    font-size: 16px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
}

main {
    width: min(100% - 2rem, 42rem);
    margin: 2.5rem auto;
}

header {
    margin-bottom: 1.5rem;
}

h1 {
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    line-height: 1.2;
    letter-spacing: -0.03em;
    margin: 1rem 0;
}

h2 {
    font-size: 1.4rem;
    line-height: 1.3;
    margin-top: 0;
}

.brand {
    color: #285548;
    font-weight: 750;
    font-size: 1.125rem;
    overflow-wrap: anywhere;
}

section {
    padding: 2rem;
    background: white;
    border: 1px solid #dbe3df;
    border-radius: 0.75rem;
}

@media (max-width: 30rem) {
    main {
        margin-top: 1.5rem;
    }

    section {
        padding: 1.25rem;
    }
}

[hidden] {
    display: none !important;
}

.brand-module {
    margin-left: 0.6rem;
    padding-left: 0.6rem;
    border-left: 1px solid #a8bdb4;
    font-weight: 450;
}

label {
    display: block;
    font-weight: 600;
    margin: 1rem 0 0.4rem;
}

input, select, textarea {
    display: block;
    width: 100%;
    min-height: 3rem;
    padding: 0.7rem;
    border: 1px solid #82998d;
    border-radius: 0.35rem;
    font: inherit;
    background: white;
    color: inherit;
}

textarea {
    resize: vertical;
}

input:focus, select:focus, textarea:focus, button:focus-visible, .messages:focus-visible {
    outline: 3px solid #78b69a;
    outline-offset: 3px;
}

button {
    min-height: 3rem;
    padding: 0.8rem 1rem;
    border: 1px solid #225b45;
    border-radius: 0.4rem;
    font: inherit;
    font-weight: 650;
    cursor: pointer;
    color: white;
    background: #225b45;
}

button:hover {
    background: #174531;
}

button.secondary {
    color: #225b45;
    background: white;
}

button.secondary:hover {
    background: #edf4ef;
}

button:disabled, textarea:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

form button {
    width: 100%;
    margin-top: 1.25rem;
}

.password-field {
    position: relative;
}

.password-field input {
    padding-right: 3.5rem;
}

.password-field input[type="password"]::-ms-reveal {
    display: none;
}

.password-field .password-toggle {
    position: absolute;
    top: 0;
    right: 0;
    width: 3rem;
    height: 100%;
    margin: 0;
    padding: 0.75rem;
    border: 0;
    background: transparent;
    color: #225b45;
    display: flex;
    align-items: center;
    justify-content: center;
}

.password-field .password-toggle:hover {
    background: #edf4ef;
}

.password-toggle svg {
    width: 1.5rem;
    height: 1.5rem;
}

.password-toggle .eye-slash {
    display: none;
}

.password-toggle[aria-pressed="true"] .eye-slash {
    display: block;
}

.hint, footer {
    font-size: 0.875rem;
    color: #52645b;
}

footer {
    margin: 1.5rem 0;
    text-align: center;
}

.feedback {
    padding: 1rem 1.25rem;
    color: #812e20;
    background: #fff0eb;
    border: 1px solid #d29a87;
    border-radius: 0.4rem;
    overflow-wrap: anywhere;
}

.feedback:focus {
    outline: 2px solid #aa5842;
}

.notice {
    padding: 0.9rem 1rem;
    border: 1px solid #b8d7c8;
    border-radius: 0.4rem;
    background: #edf7f1;
    color: #225b45;
    overflow-wrap: anywhere;
    font-size: 0.875rem;
}

main.signed-in {
    width: min(100% - 3rem, 68rem);
    margin: 1.5rem auto;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.5rem;
}

.signed-in h1 {
    font-size: 1.65rem;
    margin: 0.5rem 0;
}

.signed-in .brand {
    margin: 0;
}

.signed-in .page-header > div > .hint {
    margin: 0.5rem 0 0;
}

#account {
    flex-shrink: 0;
    text-align: right;
}

#account p {
    margin: 0 0 0.2rem;
}

#account-label {
    font-weight: 600;
    overflow-wrap: anywhere;
}

#logout {
    min-height: 2.75rem;
    margin-top: 0.5rem;
    padding: 0.45rem 0.8rem;
    font-size: 0.875rem;
}

.workspace {
    display: grid;
    grid-template-columns: minmax(0, 27rem) minmax(0, 1fr);
    gap: 2rem;
    align-items: start;
}

.workspace.consultation {
    grid-template-columns: minmax(0, 27rem);
    justify-content: center;
}

.chat-column {
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    min-width: 0;
}

.chat-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.chat-toolbar button {
    min-height: 2.75rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
}

.phone-chat {
    display: flex;
    flex-direction: column;
    height: min(44rem, 76dvh);
    min-height: 28rem;
    overflow: hidden;
    border: 1px solid #b8c9c0;
    border-radius: 1.5rem;
    background: #e9efeb;
    box-shadow: 0 8px 24px #2032390d;
}

.chat-heading {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: #225b45;
    color: white;
}

.avatar {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 2.75rem;
    height: 2.75rem;
    background: #edf7f1;
    color: #225b45;
    border-radius: 50%;
    font-weight: 700;
    font-size: 1.35rem;
}

.chat-heading h2 {
    font-size: 1.125rem;
    margin: 0;
}

.chat-heading h2 span {
    font-size: 0.75rem;
    font-weight: 400;
    margin-left: 0.4rem;
}

#version-label {
    font-size: 0.6875rem;
    color: #dbe9e1;
    margin: 0.2rem 0 0;
}

.draft-note {
    text-align: center;
    font-size: 0.6875rem;
    color: #52645b;
    margin: 0;
    padding: 0.6rem;
}

#readonly-notice {
    margin: 0 0.75rem 0.5rem;
    padding: 0.65rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #812e20;
    background: #fff0eb;
    border-color: #d29a87;
}

.messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0.25rem 0.9rem 0.75rem;
    scrollbar-width: thin;
}

.message {
    width: fit-content;
    max-width: 88%;
    padding: 0.65rem 0.85rem;
    margin: 0.6rem 0;
    border: 1px solid #dbe3df;
    border-radius: 0 0.9rem 0.9rem;
    background: white;
    overflow-wrap: anywhere;
    box-shadow: 0 1px 2px #20323908;
    font-size: 0.9375rem;
    line-height: 1.5;
}

.message.user {
    margin-left: auto;
    background: #dcefe3;
    border-color: #c5dece;
    border-radius: 0.9rem 0 0.9rem 0.9rem;
}

.message h3 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    font-size: 0.6875rem;
    color: #285548;
    margin: 0 0 0.25rem;
}

.message p {
    white-space: pre-wrap;
    margin: 0;
}

.message-status {
    font-weight: 400;
}

.pending-message {
    border-style: dashed;
}

.reply-state {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.3rem 0.5rem;
    align-self: flex-start;
    max-width: calc(100% - 1.8rem);
    margin: 0 0.9rem 0.75rem;
    padding: 0.65rem 0.85rem;
    border: 1px solid #dbe3df;
    border-radius: 0 0.9rem 0.9rem;
    background: white;
    color: #52645b;
    font-size: 0.8125rem;
}

.reply-state p {
    margin: 0;
    flex: 1;
}

#reply-elapsed {
    width: 100%;
    padding-left: 1.5rem;
    font-size: 0.6875rem;
}

.spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
    border: 2px solid #b8d7c8;
    border-top-color: #225b45;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.reply-state[data-state="error"] {
    color: #812e20;
    background: #fff0eb;
    border-color: #d29a87;
}

.reply-state[data-state="error"] .spinner {
    display: none;
}

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

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

#message-form {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    margin: 0;
    padding: 0.75rem;
    border-top: 1px solid #dbe3df;
    background: #f3f6f5;
}

#message {
    flex: 1;
    min-width: 0;
    min-height: 3rem;
    max-height: 9rem;
    resize: none;
    border-color: #c4d2ca;
    border-radius: 1.5rem;
    padding: 0.7rem 1rem;
    line-height: 1.5;
}

#send {
    display: grid;
    place-items: center;
    width: 3rem;
    height: 3rem;
    flex-shrink: 0;
    margin: 0;
    padding: 0;
    border-radius: 50%;
}

.composer-hint {
    text-align: center;
    color: #52645b;
    font-size: 0.6875rem;
    margin: 0.6rem 0 0;
}

.empty-chat {
    margin: 1.5rem auto;
    max-width: 17rem;
    text-align: center;
    padding: 1rem;
    color: #52645b;
    font-size: 0.875rem;
}

.training-panel {
    margin-top: 3.5rem;
    border: 1px solid #dbe3df;
    border-radius: 0.75rem;
    background: white;
}

.training-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 1.25rem;
    border-bottom: 1px solid #dbe3df;
}

.training-heading h2 {
    margin: 0;
    font-size: 1.05rem;
}

.upcoming {
    padding: 0.2rem 0.65rem;
    border-radius: 1rem;
    background: #edf4ef;
    color: #52645b;
    font-size: 0.6875rem;
}

.training-empty {
    padding: 3rem 2rem;
    text-align: center;
    color: #52645b;
}

.training-empty svg {
    color: #82998d;
}

.training-empty h3 {
    font-size: 1rem;
    color: #203239;
    margin: 1rem 0 0.5rem;
}

.training-empty p {
    font-size: 0.875rem;
    max-width: 23rem;
    margin: 0.5rem auto;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 48rem) {
    .workspace {
        grid-template-columns: minmax(0, 1fr);
        max-width: 27rem;
        margin: 0 auto;
        gap: 1.5rem;
    }

    .training-panel {
        margin-top: 0;
    }

    .page-header {
        flex-wrap: wrap;
        gap: 1rem;
    }

    #account {
        text-align: left;
    }
}

@media (max-width: 30rem) {
    main.signed-in {
        width: calc(100% - 1rem);
        margin: 1rem auto;
    }

    .signed-in .page-header {
        padding: 0 0.5rem;
    }

    .signed-in h1 {
        font-size: 1.35rem;
    }

    .signed-in #account {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        width: 100%;
        gap: 0.25rem 0.75rem;
    }

    #account-label {
        font-size: 0.8125rem;
    }

    .signed-in #session-time {
        font-size: 0.75rem;
    }

    #logout {
        margin: 0;
    }

    .phone-chat {
        border-radius: 1rem;
        height: 70dvh;
    }

    .chat-heading {
        padding: 0.85rem 1rem;
    }

    .training-empty {
        padding: 2rem 1rem;
    }
}

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

.history-panel {
    margin-bottom: 0.75rem;
    padding: 1rem;
    border: 1px solid #dbe3df;
    border-radius: 0.75rem;
    background: #fff;
}

.history-panel h2 {
    margin: 0;
    font-size: 1rem;
}

.history-list {
    max-height: 16rem;
    overflow-y: auto;
    list-style: none;
    padding: 0;
    margin: 0.5rem 0;
}

.history-entry {
    display: block;
    width: 100%;
    margin-bottom: 0.5rem;
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
}

.history-entry span {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.75rem;
}

.history-entry[aria-current="true"] {
    background: #e8f2ec;
    border-color: #225b45;
}

.return-current {
    margin-bottom: 0.75rem;
}

.annotation-panel-body {
    padding: 1.25rem;
    min-width: 0;
    background: #e5ede8;
    border-radius: 0 0 0.75rem 0.75rem;
}

.annotate-button.secondary {
    padding: 0.1rem 0.4rem;
    min-height: 1.75rem;
    line-height: 1;
    font-size: 1.1rem;
    border-color: transparent;
}

.annotation-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin: 0.75rem 0;
}

.annotation-actions button, #annotation-more {
    min-height: 2.5rem;
    padding: 0.4rem 0.65rem;
    font-size: 0.8125rem;
    width: auto;
    margin: 0;
}

.annotation-card {
    padding: 1rem;
    margin-top: 1rem;
    border: 1px solid #dbe3df;
    border-radius: 0.75rem;
    background: white;
    overflow-wrap: anywhere;
}

.annotation-source {
    padding: 0.75rem;
    border-radius: 0.5rem;
    background: #f3f6f5;
    color: #52645b;
    font-size: 0.8125rem;
}

.annotation-source > strong {
    color: #225b45;
}

.annotation-jump.secondary {
    width: auto;
    min-height: 2rem;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    font-size: 0.8125rem;
    text-decoration: underline;
    text-underline-offset: 0.2rem;
}

.annotation-note-label {
    margin: 1rem 0 0.25rem;
    font-size: 0.75rem;
    color: #52645b;
}

.message-reference {
    margin-left: auto;
    font-size: 0.6875rem;
    font-weight: 400;
    color: #52645b;
}

.message.annotation-selected, .annotation-card.annotation-selected {
    outline: 2px solid #225b45;
    outline-offset: 2px;
}

.annotation-card blockquote, #annotation-reference {
    margin: 0.5rem 0;
    border-left: 3px solid #b8d7c8;
    padding: 0 0.75rem;
    color: #52645b;
    font-size: 0.8125rem;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    white-space: pre-wrap;
}

.annotation-note {
    margin: 0.25rem 0 0.75rem;
    white-space: pre-wrap;
    font-size: 0.9375rem;
}

.annotation-card .annotation-actions {
    margin-bottom: 0;
}

.annotation-attachment {
    display: block;
    color: #225b45;
    font-size: 0.8125rem;
    overflow-wrap: anywhere;
}

#annotation-form {
    padding: 1rem;
    margin: 1rem 0;
    border: 1px solid #b8d7c8;
    border-radius: 0.5rem;
    background: #f3f6f5;
}

#annotation-form h3, #annotation-count {
    margin: 0.25rem 0;
}

#annotation-file {
    font-size: 0.8125rem;
    min-width: 0;
}

#annotation-progress {
    width: 100%;
    accent-color: #225b45;
}

button.danger {
    color: #812e20;
    border-color: #d29a87;
}

.workspace-nav {
    display: flex;
    gap: 0.5rem;
    margin: 0 0 1.5rem;
}

.workspace-nav button[aria-pressed="true"], .refinement-steps button[aria-current="step"] {
    background: #225b45;
    color: white;
}

.refinement-panel {
    padding: 1.75rem;
}

.refinement-heading, .refinement-section-heading, .refinement-bottom, .refinement-selection {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.refinement-heading h2, .refinement-section-heading h3, .refinement-heading p, .refinement-section-heading p {
    margin: 0;
}

.refinement-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.refinement-preview {
    background: #edf4ef;
    border-left: 3px solid #78b69a;
    border-radius: 0.25rem;
    padding: 0.75rem 1rem;
    color: #405c4e;
    font-size: 0.875rem;
}

.refinement-steps {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.5rem;
    margin: 1.5rem 0 2rem;
}

.refinement-steps button {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.65rem;
    font-size: 0.875rem;
    margin: 0;
}

.refinement-steps span {
    display: grid;
    place-items: center;
    border: 1px solid currentColor;
    border-radius: 50%;
    width: 1.5rem;
    height: 1.5rem;
    flex-shrink: 0;
    font-size: 0.75rem;
}

.refinement-filters, .refinement-comparison {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.refinement-filters select {
    text-overflow: ellipsis;
}

.refinement-notes {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    gap: 1rem;
    padding: 1rem;
    border-radius: 0.75rem;
    background: #e5ede8;
}

.refinement-note {
    min-width: 0;
    padding: 1.25rem;
    border: 1px solid #b8cec2;
    border-radius: 0.65rem;
    background: white;
    overflow-wrap: anywhere;
}

.refinement-note.is-selected {
    border-color: #225b45;
    box-shadow: 0 0 0 1px #225b45;
}

.refinement-note label {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin: 0;
    cursor: pointer;
}

.refinement-note input[type="checkbox"] {
    width: 1.125rem;
    height: 1.125rem;
    min-height: 0;
    flex-shrink: 0;
    accent-color: #225b45;
}

.refinement-note blockquote {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    border-left: 3px solid #b8d7c8;
    padding-left: 0.75rem;
    margin: 1rem 0;
    color: #52645b;
    font-size: 0.8125rem;
}

.refinement-note summary {
    color: #225b45;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0.75rem 0;
}

.refinement-note details p {
    padding: 0.75rem;
    background: #f3f6f5;
    border-radius: 0.4rem;
    font-size: 0.8125rem;
    white-space: pre-wrap;
}

.refinement-note details p.refinement-context-target {
    border: 2px solid #d97706;
    background: #fff7ed;
}

.refinement-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2rem 0.75rem;
    color: #52645b;
}

.refinement-selection {
    position: sticky;
    bottom: 0;
    margin-top: 1.5rem;
    padding: 1rem;
    border: 1px solid #b8cec2;
    border-radius: 0.5rem;
    background: #f3f6f5;
    box-shadow: 0 -4px 16px rgb(32 50 57 / 5%);
}

.refinement-selection p {
    margin: 0.25rem 0 0;
    font-size: 0.75rem;
}

.refinement-review {
    display: grid;
    grid-template-columns: 13rem minmax(0, 1fr);
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.refinement-topics, .refinement-placeholder {
    padding: 1.25rem;
    border-radius: 0.5rem;
    background: #f3f6f5;
    color: #52645b;
}

.refinement-topics h4, .refinement-placeholder h4 {
    margin-top: 0;
    color: #203239;
}

.refinement-comparison .refinement-placeholder {
    min-height: 12rem;
    border: 1px dashed #b8cec2;
}

.refinement-bottom {
    border-top: 1px solid #dbe3df;
    margin-top: 2rem;
    padding-top: 1.25rem;
}

.refinement-test-chat {
    max-width: 34rem;
    margin: 1.5rem auto;
    border: 1px solid #b8cec2;
    border-radius: 0.75rem;
    overflow: hidden;
    background: #e8efe9;
}

.refinement-test-chat h4, .refinement-test-chat .chat-heading p {
    margin: 0;
}

.refinement-test-empty {
    padding: 4rem 2rem;
    text-align: center;
    color: #52645b;
}

.refinement-test-composer {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    background: #f3f6f5;
}

.refinement-test-composer input {
    min-width: 0;
}

.refinement-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

.refinement-summary div {
    padding: 1rem;
    border: 1px solid #dbe3df;
    border-radius: 0.5rem;
}

.refinement-summary dt {
    color: #52645b;
    font-size: 0.8125rem;
}

.refinement-summary dd {
    margin: 0.5rem 0 0;
    font-weight: 650;
}

@media (max-width: 48rem) {
    .refinement-panel {
        padding: 1rem;
    }

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

    .refinement-filters, .refinement-notes, .refinement-review, .refinement-comparison {
        grid-template-columns: minmax(0, 1fr);
    }

    .refinement-selection {
        position: static;
    }

    .refinement-notes {
        padding: 0.75rem;
    }

    .refinement-selection button {
        width: 100%;
    }
}

.refinement-note-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    margin-top: 0.75rem;
}

.refinement-note-actions button {
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
}

.refinement-rejection-form {
    width: 100%;
    padding-top: 0.5rem;
}

.refinement-rejection-form label {
    display: block;
    margin-bottom: 0.5rem;
}

.refinement-decision {
    padding: 0.75rem;
    background: #fff7ed;
    border-left: 3px solid #d97706;
    white-space: pre-wrap;
    font-size: 0.8125rem;
}

.refinement-action-error {
    color: #9d2713;
    font-size: 0.8125rem;
}

#proposal-topics {
    display: grid;
    gap: 0.65rem;
}

#proposal-topics button {
    text-align: left;
    padding: 0.65rem;
    overflow-wrap: anywhere;
    font-size: 0.8125rem;
}

#proposal-content {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font: inherit;
    font-size: 0.875rem;
    max-height: 36rem;
    overflow: auto;
    padding: 0.75rem;
    border: 1px solid #b8cec2;
    border-radius: 0.4rem;
    background: #f3f6f5;
}

#proposal-content:not([readonly]) {
    background: white;
    border-color: #225b45;
}

#proposal-sources {
    margin-bottom: 1rem;
}


.proposal-diff-toolbar, .proposal-diff-legend {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.proposal-diff-toolbar label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    margin: 0;
}

.proposal-diff-toolbar input {
    width: auto;
    margin: 0;
}

.proposal-diff-legend {
    justify-content: flex-start;
    font-size: 0.8125rem;
}

.proposal-removed-key {
    color: #9d2713;
}

.proposal-added-key {
    color: #225b45;
}

.proposal-diff-heading, .proposal-diff-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.proposal-diff-heading h4 {
    margin: 0;
    padding: 0.75rem;
    font-size: 0.875rem;
    background: #f3f6f5;
}

#proposal-diff {
    border: 1px solid #b8cec2;
    border-radius: 0 0 0.4rem 0.4rem;
    overflow: hidden;
}

.proposal-diff-row + .proposal-diff-row, .proposal-unchanged + .proposal-diff-row, .proposal-diff-row + .proposal-unchanged {
    border-top: 1px solid #dbe3df;
}

.proposal-diff-cell {
    padding: 0.75rem;
    min-width: 0;
}

.proposal-diff-cell + .proposal-diff-cell {
    border-left: 1px solid #dbe3df;
}

.proposal-diff-text {
    margin: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font: inherit;
    font-size: 0.875rem;
    line-height: 1.6;
}

.proposal-removed {
    background: #fff4f0;
}

.proposal-added {
    background: #edf7f0;
}

.proposal-diff-text del {
    background: #f9d2c9;
    color: #80200f;
    text-decoration: line-through;
}

.proposal-diff-text ins {
    background: #c4e8cd;
    color: #174a34;
    text-decoration: underline;
    font-weight: 600;
}

.proposal-diff-label {
    display: none;
}

.proposal-unchanged summary {
    padding: 0.65rem 0.75rem;
    background: #f3f6f5;
    color: #52645b;
    cursor: pointer;
    font-size: 0.8125rem;
}

#proposal-editor {
    margin-top: 1.25rem;
}

#proposal-editor textarea {
    width: 100%;
    min-height: 16rem;
}

@media (max-width: 700px) {
    .proposal-diff-heading {
        display: none;
    }

    .proposal-diff-row {
        grid-template-columns: minmax(0, 1fr);
    }

    .proposal-diff-cell + .proposal-diff-cell {
        border-left: 0;
        border-top: 1px solid #dbe3df;
    }

    .proposal-diff-label {
        display: block;
        margin-bottom: 0.5rem;
        font-size: 0.8125rem;
        font-weight: 700;
    }
}

.candidate-messages {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
    min-height: 16rem;
    max-height: 32rem;
    overflow-y: auto;
}

.candidate-status {
    margin: 0;
    padding: 0.5rem 1rem;
}

.refinement-test-composer textarea {
    flex: 1;
    min-width: 0;
    resize: vertical;
    max-height: 10rem;
}

.refinement-test-composer button {
    align-self: flex-end;
}

.refinement-test-composer button {
    width: auto;
    flex: 0 0 auto;
}

.draft-observations {
    margin-top: 1.5rem;
    padding: 1rem;
    border: 1px solid #b6cfc4;
    border-radius: 12px;
    background: #e8efec;
}

#observation-list {
    display: grid;
    gap: 1rem;
    margin: 1rem 0;
}

#observation-form {
    margin-top: 1rem;
}

#observation-text {
    width: 100%;
    box-sizing: border-box;
    resize: vertical;
}

#observation-reference {
    margin: 0 0 1rem;
    padding: .75rem;
    border-left: 3px solid #d58234;
    white-space: pre-wrap;
    max-height: 10rem;
    overflow: auto;
}

.observation-target {
    border: 2px solid #d58234;
    border-radius: 8px;
    padding: .75rem;
}

#observation-list p {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.candidate-annotate {
    width: auto;
    font-size: .85rem;
    margin-top: .5rem;
    padding: .35rem .65rem;
}

.publication-change {
    margin: 12px 0;
    padding: 14px;
    border: 1px solid #b3d1c3;
    border-radius: 8px;
    background: #fff;
}

.publication-change > summary {
    cursor: pointer;
    font-weight: 700;
}

.publication-change .proposal-diff {
    margin-top: 14px;
}

.publication-notes {
    padding-left: 22px;
}

.publication-notes li {
    margin-bottom: 12px;
    overflow-wrap: anywhere;
}

.issue-card {
    padding: 18px;
    margin: 14px 0;
    border: 1px solid #b3d1c3;
    border-left: 4px solid #c87b35;
    border-radius: 8px;
    background: #f3f6f5;
    overflow-wrap: anywhere;
}

.issue-form, .issue-card .annotation-actions {
    margin-top: 14px;
}

.issue-result {
    padding: 12px;
    background: #fff;
    border-radius: 6px;
}

.issue-card[data-status="resolved"] {
    border-left-color: #225e49;
}

.issue-comparison {
    margin: 16px 0;
    padding: 12px;
    background: #fff;
    border: 1px solid #b3d1c3;
    border-radius: 6px;
}

.issue-comparison .proposal-diff {
    margin-top: 8px;
}

#proposal-advanced {
    margin: 18px 0;
}

#proposal-advanced > summary {
    color: #225e49;
    font-weight: 600;
    margin-bottom: 12px;
}

body.model-waiting {
    overflow: hidden;
}

#model-wait {
    width: min(28rem, calc(100vw - 2rem));
    max-height: calc(100dvh - 2rem);
    margin: auto;
    padding: 2rem;
    border: 1px solid #b3d1c3;
    border-radius: 12px;
    background: #fff;
    color: #203239;
    text-align: center;
    box-shadow: 0 12px 48px #20323933;
}

#model-wait::backdrop {
    background: rgb(32 50 57 / 48%);
}

#model-wait .spinner {
    width: 3rem;
    height: 3rem;
    border-width: 4px;
    margin-bottom: 0.75rem;
}

#model-wait h2 {
    font-size: 1.25rem;
    margin: 0 0 0.75rem;
}

#model-wait p:last-child {
    margin-bottom: 0;
}

body.model-waiting #reply-state .spinner {
    visibility: hidden;
}
