.knowledge-starter {
    align-items: center;
    background: #fff;
    border: 1px solid var(--line);
    display: flex;
    gap: 28px;
    justify-content: space-between;
    margin: 26px 0;
    padding: 24px 28px;
}

.knowledge-nav {
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 1rem;
    margin: 1.5rem 0 2rem;
    overflow-x: auto;
}

.knowledge-nav a {
    color: var(--muted);
    padding: .7rem .2rem;
    white-space: nowrap;
}

.knowledge-nav a.active {
    border-bottom: 2px solid var(--gold);
    color: var(--ink);
    font-weight: 600;
}

.memory-create {
    align-items: end;
    display: grid;
    gap: .6rem;
    grid-template-columns: 1fr auto;
    margin: 1.5rem 0 2rem;
}

.memory-list {
    display: grid;
    gap: .75rem;
}

.memory-section {
    margin: 2.5rem 0;
}

.memory-section-heading {
    align-items: end;
    display: flex;
    gap: 2rem;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.memory-section-heading h2 {
    font: 600 clamp(1.55rem, 2.4vw, 2.2rem) 'Playfair Display';
    margin: .25rem 0 0;
}

.memory-section-heading p {
    color: var(--muted);
    line-height: 1.5;
    margin: 0;
    max-width: 520px;
}

.memory-fact-list {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.memory-fact-card {
    background: #fff;
    border: 1px solid var(--line);
    border-left: 4px solid #789084;
    display: grid;
    gap: 1rem;
    min-width: 0;
    padding: 1.25rem;
}

.memory-fact-card.status-review,
.memory-fact-card.status-contradicted {
    border-left-color: #b78a3c;
}

.memory-fact-card > header,
.memory-fact-badges,
.memory-fact-meta,
.memory-fact-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.memory-fact-card > header {
    align-items: start;
    justify-content: space-between;
}

.memory-fact-card h3 {
    font-size: .82rem;
    letter-spacing: .08em;
    margin: .25rem 0 0;
    text-transform: uppercase;
}

.memory-fact-subject {
    color: var(--muted);
    font-size: .9rem;
}

.memory-fact-value {
    font: 600 clamp(1.15rem, 2vw, 1.45rem) 'Inter', sans-serif;
    line-height: 1.35;
    margin: 0;
    overflow-wrap: anywhere;
}

.fact-badge {
    background: #f2efe8;
    border: 1px solid #e1dbcd;
    border-radius: 999px;
    color: #615b50;
    font-size: .75rem;
    padding: .35rem .55rem;
}

.status-review .fact-status,
.status-contradicted .fact-status {
    background: #fff5df;
    border-color: #e2c98f;
    color: #795819;
}

.memory-fact-meta {
    color: var(--muted);
    font-size: .8rem;
}

.memory-fact-meta span:not(:last-child)::after {
    content: '·';
    margin-left: .5rem;
}

.memory-fact-proof {
    border-top: 1px solid var(--line);
    padding-top: .8rem;
}

.memory-fact-proof summary,
.memory-fact-actions summary {
    color: var(--gold-dark, #80611f);
    cursor: pointer;
    font-weight: 600;
}

.memory-fact-proof p {
    align-items: baseline;
    display: grid;
    gap: .2rem;
    grid-template-columns: minmax(110px, auto) 1fr auto;
    margin: .75rem 0 0;
}

.memory-fact-proof span,
.memory-fact-proof small {
    color: var(--muted);
    overflow-wrap: anywhere;
}

.memory-fact-actions {
    border-top: 1px solid var(--line);
    padding-top: .85rem;
}

.memory-fact-actions > details {
    flex: 1 1 260px;
}

.memory-fact-actions details form {
    align-items: center;
    display: flex;
    gap: .5rem;
    margin-top: .75rem;
}

.memory-fact-actions input {
    flex: 1;
    min-width: 120px;
}

.memory-pagination {
    margin-top: 1.5rem;
}

.memory-card {
    background: #fff;
    border: 1px solid var(--line);
    padding: 1rem;
}

.memory-card > form:first-child,
.memory-card > form:first-child > div {
    align-items: center;
    display: flex;
    gap: .75rem;
}

.memory-card > form:first-child {
    align-items: stretch;
}

.memory-card textarea {
    flex: 1;
    resize: vertical;
}

.memory-card > form:first-child > div {
    align-items: flex-end;
    flex-direction: column;
    justify-content: space-between;
}

.memory-card small {
    color: var(--muted);
    white-space: nowrap;
}

.profile-page {
    max-width: none;
    width: min(980px, calc(100% - 40px));
}

.profile-intro {
    line-height: 1.6;
    max-width: 720px;
}

.profile-form {
    display: grid;
    gap: 1rem;
    margin-top: 2rem;
}

.profile-section {
    background: #fff;
    border: 1px solid var(--line);
    display: grid;
    gap: 2rem;
    grid-template-columns: 230px minmax(0, 1fr);
    padding: 1.5rem;
}

.profile-section h2 {
    font: 600 22px 'Playfair Display';
    margin: .3rem 0 0;
}

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

.profile-grid-text label {
    align-content: start;
}

.profile-grid textarea {
    min-height: 110px;
    resize: vertical;
}

.profile-save {
    align-items: center;
    background: #efe7d5;
    border: 1px solid #d7c49a;
    display: flex;
    gap: 2rem;
    justify-content: space-between;
    padding: 1rem 1.25rem;
}

.profile-save p,
.profile-save strong,
.profile-save span {
    display: block;
    margin: 0;
}

.profile-save span {
    color: var(--muted);
    font-size: .8rem;
    margin-top: .2rem;
}

.relationships-page {
    max-width: none;
    width: min(1080px, calc(100% - 40px));
}

.relationship-upcoming,
.relationship-create,
.relationship-list {
    margin-top: 2rem;
}

.relationship-upcoming {
    background: #fff;
    border: 1px solid var(--line);
    display: grid;
    gap: .75rem;
    padding: 1.4rem;
}

.relationship-upcoming h2 {
    font: 600 24px 'Playfair Display';
    margin: .2rem 0 0;
}

.relationship-event {
    align-items: center;
    background: #fbfaf7;
    border: 1px solid var(--line);
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    padding: 1rem;
}

.relationship-event.needs-action {
    background: #fff8df;
    border-color: #d8bf7d;
}

.relationship-event strong,
.relationship-event span,
.relationship-event small,
.relationship-card-heading strong,
.relationship-card-heading span,
.relationship-card-heading small {
    display: block;
}

.relationship-event span,
.relationship-card-heading span,
.relationship-card-heading small {
    color: var(--muted);
}

.relationship-profile-link {
    align-items: baseline;
    color: inherit;
    display: flex;
    flex-wrap: wrap;
    gap: .35rem .7rem;
    text-decoration: none;
}

.relationship-profile-link span {
    color: var(--gold);
    font-size: .76rem;
    font-weight: 750;
}

.relationship-profile-link:hover strong,
.relationship-profile-link:focus-visible strong {
    color: var(--gold);
}

.relationship-profile-link:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 4px;
}

.relationship-event button {
    white-space: nowrap;
}

.relationship-create {
    background: #fff;
    border: 1px solid var(--line);
    padding: 1.2rem;
}

.relationship-create summary,
.relationship-card summary {
    cursor: pointer;
    font-weight: 700;
}

.relationship-form {
    margin-top: 1rem;
}

.relationship-list {
    display: grid;
    gap: 1rem;
}

.relationship-card {
    background: #fff;
    border: 1px solid var(--line);
    display: grid;
    gap: 1rem;
    padding: 1.2rem;
}

.relationship-card-heading {
    align-items: start;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
}

.relationship-card-heading strong {
    font: 600 22px 'Playfair Display';
}

@media (max-width: 760px) {
    .relationship-event,
    .relationship-card-heading {
        align-items: stretch;
        display: grid;
    }
}

.history-search {
    align-items: end;
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(0, 1fr) auto auto;
}

.history-search label {
    display: grid;
    gap: 7px;
}

.history-search button,
.history-search a {
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 10px;
    display: inline-flex;
    font-weight: 750;
    justify-content: center;
    min-height: 46px;
    padding: 10px 16px;
    text-decoration: none;
}

.history-search button {
    background: var(--ink);
    color: #fff;
}

.history-result-count {
    color: var(--muted);
    margin: 14px 0 0;
}

.history-row > a em {
    color: var(--muted);
    display: block;
    font-size: 13px;
    font-style: normal;
    font-weight: 500;
    line-height: 1.45;
    margin-top: 7px;
}

@media (max-width: 680px) {
    .history-search {
        grid-template-columns: 1fr 1fr;
    }

    .history-search label {
        grid-column: 1 / -1;
    }
}

.knowledge-starter h2 {
    font: 600 24px 'Playfair Display';
    margin: 0 0 6px;
}

.knowledge-starter p {
    line-height: 1.55;
    margin: 0;
    max-width: 470px;
}

.knowledge-starter form,
.knowledge-starter button {
    flex: 0 0 auto;
}

.mailbox-health {
    margin-top: 5px;
}

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

.mailbox-actions form {
    margin: 0;
}

.danger-button {
    color: #9f3434 !important;
}

.message-sources {
    border-left: 2px solid var(--line);
    color: var(--muted);
    margin: 14px 0 10px;
    padding-left: 14px;
}

.message-sources summary {
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}

.message-sources ul {
    display: grid;
    gap: 8px;
    list-style: none;
    margin: 10px 0 0;
    padding: 0;
}

.message-sources li {
    display: grid;
    font-size: 12px;
    gap: 2px;
}

.message-sources a {
    color: var(--ink);
    text-decoration: underline;
    text-decoration-color: var(--line);
    text-underline-offset: 3px;
}

.sidebar-tools {
    display: grid;
    gap: .4rem;
    grid-template-columns: repeat(2, 1fr);
    margin: -18px 0 20px;
}

.chat-launchers {
    display: grid;
    gap: .5rem;
    margin: 30px 0 14px;
}

.chat-launchers .new-chat {
    margin: 0;
}

.temporary-chat-button {
    background: transparent;
    border: 1px solid #4a4943;
    border-radius: 4px;
    color: #d3d0c8;
    cursor: pointer;
    font: inherit;
    font-size: .82rem;
    padding: .65rem .8rem;
    width: 100%;
}

.temporary-chat-button:hover {
    border-color: #b69a5b;
    color: #fff;
}

.chat-launchers + .sidebar-tools {
    margin: 0 0 20px;
}

.ephemeral-badge {
    background: #f2ead7;
    border: 1px solid #d5bd84;
    border-radius: 999px;
    color: #735b27;
    display: inline-block;
    font-size: .72rem;
    margin-left: .6rem;
    padding: .22rem .55rem;
}

.temporary-chat-notice {
    align-items: center;
    background: #fbf6e9;
    border: 1px solid #dbc898;
    display: flex;
    gap: .8rem;
    margin: 1rem auto;
    max-width: 900px;
    padding: .75rem 1rem;
}

.temporary-chat-notice span {
    color: var(--muted);
    font-size: .82rem;
}

.ephemeral-delete {
    color: #8c7137;
}

.sidebar-tools a {
    border: 1px solid #3a3934;
    border-radius: 4px;
    color: #d3d0c8;
    font-size: .82rem;
    padding: .7rem .8rem;
    text-align: center;
}

.sidebar-tools a:hover {
    border-color: #b69a5b;
    color: #fff;
}

.sidebar-footer {
    display: grid;
    gap: .35rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
}

.sidebar-footer > a,
.sidebar-footer .link-button {
    align-items: center;
    border-radius: 4px;
    display: flex;
    font-size: .78rem;
    gap: .45rem;
    min-width: 0;
    padding: .6rem .55rem;
    text-align: left;
}

.sidebar-footer > a:hover,
.sidebar-footer .link-button:hover {
    background: #2b2b27;
    color: #fff;
}

.sidebar-footer > a span,
.sidebar-footer .link-button span {
    color: #b69a5b;
    flex: 0 0 1rem;
    text-align: center;
}

.sidebar-footer form {
    border-top: 1px solid #34342f;
    grid-column: 1 / -1;
    margin-top: .25rem;
    padding-top: .35rem;
}

.sidebar-footer .link-button {
    width: 100%;
}

.contacts-page {
    max-width: 980px;
}

.contact-search {
    display: grid;
    gap: .6rem;
    grid-template-columns: 1fr auto;
    margin: 1.5rem 0;
}

.crm-toolbar {
    align-items: center;
    background: #fff;
    border: 1px solid var(--line);
    display: flex;
    gap: 20px;
    justify-content: space-between;
    margin: 1rem 0 1.5rem;
    padding: 1rem;
}

.crm-toolbar strong,
.crm-toolbar small {
    display: block;
}

.crm-toolbar small {
    color: var(--muted);
    margin-top: .25rem;
}

.contact-create {
    margin: 1rem 0 2rem;
}

.contact-create summary {
    color: #8c7137;
    cursor: pointer;
    font-weight: 600;
    padding: .75rem 0;
}

.contact-list {
    display: grid;
    gap: .8rem;
}

.contact-card {
    background: #fff;
    border: 1px solid var(--line);
    padding: 1rem;
}

.contact-card > form:first-child {
    display: grid;
    gap: .75rem;
}

.contact-heading,
.contact-actions {
    align-items: center;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
}

.contact-heading input {
    border: 0;
    font-size: 1.05rem;
    font-weight: 600;
    padding: .2rem 0;
}

.contact-heading small,
.contact-actions small,
.contact-card > small {
    color: var(--muted);
}

.contact-fields {
    display: grid;
    gap: .7rem;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.contact-fields input,
.contact-fields select {
    padding: .6rem;
}

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

.contact-write,
.contact-history,
.contact-company,
.contact-call,
.contact-website {
    color: #8c7137;
    font-size: .78rem;
    font-weight: 600;
}

.contact-history,
.contact-company,
.contact-call {
    color: var(--ink);
}

.contact-shared-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: .9rem;
}

.link-danger {
    background: transparent;
    color: #9f3434;
    font-size: .75rem;
    padding: .3rem 0;
}

.draft-create {
    margin: 1.5rem 0;
}

.draft-create summary {
    color: #8c7137;
    cursor: pointer;
    font-weight: 600;
    padding: .75rem 0;
}

.draft-create .settings-form {
    margin-top: .5rem;
}

.actions-page {
    max-width: 1050px;
}

.action-tabs {
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 1rem;
    margin: 1.5rem 0;
}

.action-tabs a {
    color: var(--muted);
    padding: .7rem .2rem;
}

.action-tabs a.active {
    border-bottom: 2px solid var(--gold);
    color: var(--ink);
    font-weight: 600;
}

.action-create,
.email-action-create {
    margin: 1rem 0 2rem;
}

.action-create summary,
.email-action-create summary {
    color: #8c7137;
    cursor: pointer;
    font-weight: 600;
    padding: .75rem 0;
}

.email-action-create .settings-form {
    margin-top: .5rem;
}

.action-list {
    display: grid;
    gap: .8rem;
}

.action-card {
    background: #fff;
    border: 1px solid var(--line);
    border-left: 4px solid #aaa59a;
    padding: 1rem;
}

.action-card.priority-high {
    border-left-color: #b78436;
}

.action-card.priority-urgent {
    border-left-color: #a43b36;
}

.action-card.priority-low {
    border-left-color: #8aa0a7;
}

.action-card > form:first-child {
    display: grid;
    gap: .75rem;
}

.action-heading,
.action-meta {
    align-items: center;
    display: flex;
    gap: .8rem;
    justify-content: space-between;
}

.action-heading input {
    border: 0;
    font-size: 1.05rem;
    font-weight: 600;
    padding: .2rem 0;
}

.action-priority {
    background: #f1eee7;
    border-radius: 999px;
    color: var(--muted);
    flex: 0 0 auto;
    font-size: .7rem;
    padding: .3rem .6rem;
}

.action-fields {
    display: grid;
    gap: .65rem;
    grid-template-columns: repeat(3, 1fr);
}

.action-fields input,
.action-fields select {
    padding: .6rem;
}

.action-meta {
    color: var(--muted);
    font-size: .75rem;
    justify-content: flex-end;
}

.action-meta a {
    color: #8c7137;
}

.action-context-links {
    margin: .75rem 0 0;
}

.action-context-links a {
    color: #8c7137;
    font-size: .82rem;
    font-weight: 700;
}

.source-health {
    align-items: center;
    background: #fff;
    border: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    margin: 1.5rem 0;
    padding: 1rem;
}

.source-health strong,
.source-health small {
    display: block;
}

.document-upload {
    margin: 2rem 0 1rem;
}

.document-upload h2,
.document-upload .full-field {
    grid-column: 1 / -1;
}

.document-upload input[type='file'] {
    background: #faf8f3;
    border-style: dashed;
    padding: 1.2rem;
}

.recent-documents {
    background: #fff;
    border: 1px solid var(--line);
    padding: 1rem;
}

.recent-documents > h2 {
    margin-top: 0;
}

.recent-documents article {
    align-items: center;
    border-top: 1px solid var(--line);
    display: grid;
    gap: .8rem;
    grid-template-columns: minmax(180px, 1fr) minmax(360px, 1.5fr);
    padding: .8rem 0;
}

.recent-document-summary > strong,
.recent-document-summary > small {
    display: block;
}

.recent-document-summary > small {
    color: var(--muted);
    font-size: .75rem;
    margin-top: .2rem;
}

.document-context-links {
    display: flex;
    flex-wrap: wrap;
    gap: .45rem;
    margin-top: .7rem;
}

.document-context-links a {
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 700;
    padding: .4rem .65rem;
}

.knowledge-source-links {
    border-top: 1px solid var(--line);
    margin-top: 1rem;
    padding-top: .8rem;
}

.knowledge-document-summary strong {
    display: block;
}

.knowledge-document-summary .document-context-links {
    margin-top: .4rem;
}

.memory-fact-proof strong a {
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
    text-underline-offset: .2em;
}

.recent-documents form {
    align-items: center;
    display: grid;
    gap: .4rem;
    grid-template-columns: 1fr 1.4fr .8fr auto;
}

.recent-documents select,
.recent-documents button {
    padding: .55rem;
}

.source-health small {
    color: var(--muted);
    margin-top: .25rem;
}

.health-dot {
    background: #a58f5b;
    border-radius: 50%;
    height: .75rem;
    width: .75rem;
}

.health-dot.ok {
    background: #4f8158;
}

.search-page,
.email-page {
    max-width: 920px;
}

.global-search {
    display: grid;
    gap: .6rem;
    grid-template-columns: 1fr auto;
    margin: 1.5rem 0;
}

.global-search input {
    font-size: 1.05rem;
    padding: 1rem;
}

.search-count {
    color: var(--muted);
    font-size: .82rem;
}

.search-group {
    margin-top: 2rem;
}

.search-group h2,
.email-attachments h2 {
    font: 600 1.25rem 'Playfair Display';
}

.search-group h2 span {
    color: var(--gold);
    font: 600 .75rem 'DM Sans';
    margin-left: .35rem;
}

.search-result,
.email-attachments > a {
    align-items: center;
    background: #fff;
    border: 1px solid var(--line);
    border-bottom: 0;
    display: flex;
    justify-content: space-between;
    padding: .9rem 1rem;
}

.search-result:last-child,
.email-attachments > a:last-child {
    border-bottom: 1px solid var(--line);
}

.search-result:hover {
    border-color: var(--gold);
}

.search-result strong,
.search-result small,
.email-attachments strong,
.email-attachments small {
    display: block;
}

.search-result small,
.search-result time,
.email-attachments small {
    color: var(--muted);
    font-size: .75rem;
    margin-top: .2rem;
}

.email-meta {
    background: #fff;
    border: 1px solid var(--line);
    display: grid;
    gap: .75rem;
    grid-template-columns: 1fr 1fr;
    margin: 1.5rem 0;
    padding: 1rem;
}

.email-meta span,
.email-meta strong {
    display: block;
}

.email-meta strong {
    color: var(--muted);
    font-size: .7rem;
    letter-spacing: .08em;
    margin-bottom: .2rem;
    text-transform: uppercase;
}

.email-thread-actions {
    align-items: center;
    background: #fff;
    border: 1px solid var(--line);
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    justify-content: space-between;
    margin: 0 0 1.5rem;
    padding: 1rem;
}

.email-thread-actions div {
    flex: 1 1 220px;
}

.email-thread-actions strong,
.email-thread-actions small {
    display: block;
}

.email-thread-actions small {
    color: var(--muted);
    margin-top: .2rem;
}

.email-thread-actions form {
    margin: 0;
}

.email-thread-actions button {
    padding: .65rem .9rem;
}

.email-body {
    background: #fff;
    border: 1px solid var(--line);
    line-height: 1.75;
    padding: 1.5rem;
    white-space: pre-wrap;
}

.email-attachments {
    margin-top: 1.5rem;
}

@media (max-width: 760px) {
    .profile-section {
        gap: 1rem;
        grid-template-columns: 1fr;
    }

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

    .profile-save {
        align-items: stretch;
        flex-direction: column;
    }

    .knowledge-starter {
        align-items: stretch;
        flex-direction: column;
        padding: 22px;
    }

    .mailbox-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .global-search,
    .email-meta,
    .contact-search,
    .contact-fields {
        grid-template-columns: 1fr;
    }

    .crm-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

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

    .action-fields {
        grid-template-columns: 1fr;
    }

    .recent-documents article,
    .recent-documents form {
        grid-template-columns: 1fr;
    }

    .memory-create {
        grid-template-columns: 1fr;
    }

    .memory-section-heading {
        align-items: start;
        flex-direction: column;
        gap: .5rem;
    }

    .memory-fact-list {
        grid-template-columns: 1fr;
    }

    .memory-fact-proof p {
        grid-template-columns: 1fr;
    }

    .memory-card > form:first-child {
        flex-direction: column;
    }

    .memory-card > form:first-child > div {
        align-items: stretch;
    }
}

.deadlines-page {
    width: min(1100px, calc(100% - 40px));
}

.deadline-form .full-field {
    grid-column: 1 / -1;
}

.deadline-card {
    display: grid;
    gap: 12px;
}

.deadline-context {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 12px;
}

.deadline-context span {
    background: #fbfaf7;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: #5f5a50;
    font-size: 12px;
    font-weight: 700;
    padding: 7px 10px;
}

.deadline-card .action-heading input {
    font-size: 20px;
}

.deadline-card.priority-urgent {
    border-left-color: #9f3434;
}

.deadline-card.priority-high {
    border-left-color: #c47b38;
}

.deadline-card.priority-normal {
    border-left-color: var(--gold);
}

.deadline-card.priority-low {
    border-left-color: #7c9a6a;
}

@media (max-width: 760px) {
    .deadline-context {
        display: grid;
    }

    .deadline-form {
        grid-template-columns: 1fr;
    }
}
