* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
}

body {
    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Arial,
        sans-serif;

    background: #f4f5f7;
    color: #202124;
}

button,
input {
    font: inherit;
}


.app {
    display: flex;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}


/* ---------------------------------------------------------
   SIDEBAR
--------------------------------------------------------- */

.sidebar {
    width: 250px;
    flex-shrink: 0;

    background: #0e2755;
    color: #ffffff;

    display: flex;
    flex-direction: column;

    position: fixed;

    height: 100vh;
    top: 0;
    left: 0;
}

.logo {
    padding: 24px 20px 22px;

    border-bottom: 1px solid #3b3d40;
}

.logo-title {
    font-size: 19px;
    font-weight: 600;
    line-height: 1.3;
}

.logo-link {
    display: flex;
    align-items: center;

    gap: 11px;

    color: inherit;
    text-decoration: none;

    cursor: pointer;
}

.logo-icon {
    width: 42px;
    height: 42px;

    flex-shrink: 0;

    border-radius: 9px;
}

.logo-text {
    min-width: 0;
}

.logo-title {
    font-size: 17px;
    font-weight: 600;
    line-height: 1.25;
}

.logo-link:hover {
    color: #ffffff;
    text-decoration: none;
}

.logo-subtitle {
    margin-top: 7px;

    font-size: 12px;
    color: #aeb1b5;
}

.navigation {
    padding: 14px 10px;
    overflow-y: auto;
}

.nav-item {
    width: 100%;

    border: 0;
    border-radius: 6px;

    padding: 10px 12px;

    text-align: left;

    background: transparent;
    color: #d8dadd;

    cursor: pointer;
}

.nav-item:hover {
    background: #303236;
}

.nav-item.active {
    background: #3a3d42;
    color: #ffffff;
}

.nav-heading {
    margin: 26px 12px 8px;

    font-size: 11px;
    font-weight: 600;

    text-transform: uppercase;
    letter-spacing: 0.08em;

    color: #85888d;
}

.project-item {
    display: block;

    width: 100%;

    padding: 9px 12px;

    border: 0;
    border-radius: 6px;

    background: transparent;
    color: #cfd1d4;

    text-align: left;

    cursor: pointer;
}

.project-item:hover {
    background: #303236;
}

.project-item.active {
    background: #3a3d42;
    color: #ffffff;
}


/* ---------------------------------------------------------
   MAIN
--------------------------------------------------------- */

.main {
    display: flex;
    flex-direction: column;

    min-width: 0;
    flex: 1;

    margin-left: 250px;
}


/* ---------------------------------------------------------
   HEADER
--------------------------------------------------------- */

.header {
    height: 68px;
    flex-shrink: 0;

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 0 22px;

    background: #ffffff;

    border-bottom: 1px solid #dfe1e5;
}

.header-title {
    font-size: 20px;
    font-weight: 600;
}

.search-container {
    display: flex;
    gap: 8px;
}

.search-container select {
    padding: 9px 10px;

    border: 1px solid #c9ccd1;
    border-radius: 6px;

    background: #ffffff;

    cursor: pointer;
}

.search-container select:focus {
    outline: none;
    border-color: #777b82;
}

.search-container input {
    width: 260px;

    padding: 9px 12px;

    border: 1px solid #c9ccd1;
    border-radius: 6px;

    outline: none;

    background: #ffffff;
}

.search-container input:focus {
    border-color: #777b82;
}

.search-container button {
    padding: 9px 15px;

    border: 1px solid #c9ccd1;
    border-radius: 6px;

    background: #ffffff;

    cursor: pointer;
}

.search-container button:hover {
    background: #f0f1f2;
}


/* ---------------------------------------------------------
   CONTENT
--------------------------------------------------------- */

.content {
    display: flex;

    min-height: 0;
    flex: 1;
}


/* ---------------------------------------------------------
   CONVERSATION LIST
--------------------------------------------------------- */

.conversation-panel {
    width: 390px;
    flex-shrink: 0;

    background: #ffffff;

    border-right: 1px solid #dfe1e5;

    display: flex;
    flex-direction: column;
}

.workspace-list-toggle { margin-left: 4px; }
.conversation-panel.is-collapsed { width: 42px; }
.conversation-panel.is-collapsed .panel-header { justify-content: center; padding: 0; }
.conversation-panel.is-collapsed #list-title,
.conversation-panel.is-collapsed #conversation-count,
.conversation-panel.is-collapsed .conversation-pagination,
.conversation-panel.is-collapsed .conversation-list { display: none; }

.panel-header {
    height: 48px;
    flex-shrink: 0;

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 0 16px;

    border-bottom: 1px solid #e5e6e8;

    font-size: 13px;
    font-weight: 600;
}

.count {
    color: #8a8d91;
    font-weight: 400;
}

.conversation-pagination {
    display: flex;

    align-items: center;
    justify-content: space-between;

    gap: 8px;

    padding: 8px 12px;

    background: #ffffff;

    border-top: 1px solid #e5e6e8;
    border-bottom: 1px solid #e5e6e8;

    flex-shrink: 0;
}

.conversation-pagination .pagination-info {
    flex: 1;

    text-align: center;

    font-size: 11px;

    color: #777b80;
}

.pagination-button {
    padding: 5px 9px;

    border: 1px solid #dfe1e5;

    border-radius: 4px;

    background: #ffffff;

    color: #44484d;

    font-size: 11px;

    cursor: pointer;
}

.pagination-button:disabled {
    color: #b5b7ba;

    background: #f7f7f8;

    cursor: default;
}

#conversation-pagination-top {
    flex-shrink: 0;

    border-bottom: 1px solid #e5e6e8;
}

#conversation-pagination-top
.conversation-pagination {
    border-top: 0;
    border-bottom: 0;
}

.conversation-list
.conversation-pagination {
    border-top: 1px solid #e5e6e8;
    border-bottom: 0;

    margin-top: 0;
}

.provider-item,
.product-item {
    display: block;

    width: 100%;

    padding: 6px 10px;

    margin: 0;

    border: 0;

    border-radius: 4px;

    background: transparent;

    color: #d9dadd;

    text-align: left;

    font-size: 13px;

    cursor: pointer;
}

.provider-item:hover,
.product-item:hover {
    background: #303236;
}

.provider-item.active,
.product-item.active {
    background: #3b3e43;

    color: #ffffff;
}
.conversation-list {
    overflow-y: auto;
    flex: 1;
}

.conversation-item {
    padding: 14px 16px;

    border-bottom: 1px solid #ececee;

    cursor: pointer;
}

.conversation-item:hover {
    background: #f5f6f7;
}

.conversation-item.active {
    background: #e9eaec;
}

.bookmark-item {
    padding: 14px 16px;

    border-bottom: 1px solid #ececee;

    cursor: pointer;

    background: #ffffff;
}

.bookmark-item:hover {
    background: #f5f6f7;
}

.bookmark-title {
    font-size: 14px;
    font-weight: 600;

    line-height: 1.4;

    margin-bottom: 5px;
}

.bookmark-meta {
    font-size: 11px;
    color: #777b80;

    margin-bottom: 8px;
}

.bookmark-content {
    font-size: 12px;
    line-height: 1.5;

    color: #4f5257;

    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;

    overflow: hidden;
}

.conversation-title {
    font-size: 14px;
    font-weight: 600;

    line-height: 1.4;

    margin-bottom: 6px;
}

.conversation-meta {
    font-size: 12px;
    color: #777b80;
}

.conversation-project {
    margin-top: 5px;

    font-size: 11px;
    color: #8b8e93;
}

.loading,
.error {
    padding: 20px;

    font-size: 13px;
    color: #777b80;
}

.error {
    color: #a33;
}


/* ---------------------------------------------------------
   DETAIL
--------------------------------------------------------- */

.detail-panel {
    min-width: 0;
    flex: 1;

    background: #f7f7f8;

    overflow: hidden;
}

.conversation-detail {
    height: 100%;

    overflow-y: auto;

    padding: 28px 36px 60px;
}

.detail-header {
    max-width: 950px;

    margin: 0 auto 28px;
}

.detail-title {
    font-size: 24px;
    font-weight: 600;

    line-height: 1.35;
}

.detail-meta {
    margin-top: 8px;

    font-size: 12px;
    color: #777b80;
}

.conversation-project-assignment {
    display: block;

    margin-top: 12px;

    color: #666b73;

    font-size: 13px;
}

.conversation-project-assignment select {
    min-width: 180px;

    padding: 5px 7px;
}

.detail-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 16px;
}

.detail-controls > * { flex: 1; }

.detail-conversation-pagination {
    display: flex;

    gap: 8px;

    margin-top: 12px;
}
.detail-conversation-pagination { justify-content: flex-end; }
.project-navigation-row { display:flex; align-items:center; }
.project-navigation-row .project-item { flex:1; }
.project-conversation-count { color:#aeb8c5; }
.project-export-link { padding:6px 9px; color:#d9dadd; text-decoration:none; }
.project-export-link:hover { color:#fff; }
.media-incomplete-group { color: #8a9099; }
.media-filter-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.media-filter-bar select { min-width: 150px; max-width: 240px; }
.media-source-chooser { position: relative; min-width: 180px; }
.media-source-chooser > summary { list-style: none; cursor: pointer; min-height: 34px; box-sizing: border-box; padding: 7px 28px 7px 10px; border: 1px solid #c6ced8; border-radius: 5px; background: #fff; position: relative; }
.media-source-chooser > summary::-webkit-details-marker { display: none; }
.media-source-chooser > summary::after { content: "⌄"; position: absolute; right: 9px; }
.media-source-options { position: absolute; z-index: 20; min-width: 280px; max-height: 320px; overflow: auto; padding: 8px; border: 1px solid #c6ced8; border-radius: 5px; background: #fff; box-shadow: 0 5px 14px rgba(0,0,0,.16); }
.media-source-options label { display: flex; gap: 8px; align-items: center; padding: 5px 4px; cursor: pointer; white-space: nowrap; }
.media-tags { margin-top: 22px; display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.media-tag-list { display: flex; gap: 6px; flex-wrap: wrap; }
.media-tag { padding: 3px 8px; border: 1px solid #cbd4df; border-radius: 12px; background: #f4f7fb; color: #334a64; font-size: 12px; cursor: pointer; }
.media-entity { padding: 3px 8px; border: 1px solid #c3d9cf; border-radius: 12px; background: #f0f8f3; color: #24533a; font-size: 12px; cursor: pointer; }
.media-context { margin-top: 18px; color: #5e6873; }
.media-markdown-preview { max-width: 900px; line-height: 1.6; }
.media-readonly-content {
    box-sizing: border-box;
    width: 100%;
    margin-top: 16px;
    padding: 20px;
    border: 1px solid #c7d1db;
    border-left: 4px solid #668daf;
    border-radius: 6px;
    background: #fff;
}
.media-html-preview { width: 100%; min-height: 520px; border: 1px solid #d5dbe2; background: white; }
.media-context a { color: #255f9f; }
.settings-entity-list { margin-top: 16px; border: 1px solid #d9dde2; border-radius: 6px; overflow: hidden; }
.settings-entity-item { display: grid; grid-template-columns: minmax(0, 1fr) 28px 28px; gap: 6px; align-items: center; padding: 10px 12px; border-bottom: 1px solid #e5e7ea; }
.settings-entity-item:last-child { border-bottom: 0; }
.settings-entity-main { min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.settings-entity-main strong { overflow-wrap: anywhere; }
.settings-entity-main small { flex-basis: 100%; color: #6d747c; }
.settings-entity-type { color: #4c7160; font-size: 12px; }
.settings-entity-usage { color: #61738a !important; }
.entity-media-link { display: block; width: fit-content; margin: 7px 0; color: #255f9f; text-decoration: none; }
.entity-media-link:hover { text-decoration: underline; }
.entity-actions { display: flex; gap: 7px; }
.entity-icon-button { width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid #9eb5d2; border-radius: 4px; background: #fff; color: #174f8b; cursor: pointer; font-size: 16px; line-height: 1; }
.entity-icon-button:hover { background: #edf4fb; }
.entity-delete-button { border-color: #e2a3a3; color: #b42e2e; }
.entity-delete-button:hover { background: #fff2f2; }
.entity-media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.entity-media-link { width: auto; margin: 0; color: #255f9f; font-size: 13px; overflow-wrap: anywhere; }
.entity-media-thumb { aspect-ratio: 4 / 3; display: flex; align-items: center; justify-content: center; margin-bottom: 5px; overflow: hidden; border: 1px solid #d5dbe2; border-radius: 5px; background: #eef1f5; color: #647286; font-size: 12px; font-weight: 600; }
.entity-media-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }

.detail-conversation-pagination button {
    padding: 5px 9px;

    border: 1px solid #c9ccd1;
    border-radius: 5px;

    background: #ffffff;
    color: #303236;

    cursor: pointer;
}

.detail-conversation-pagination button:disabled {
    cursor: default;
    opacity: 0.45;
}

.conversation-exports { margin-top: 12px; display: flex; gap: 8px; justify-content: center; align-items: center; color: #666b73; font-size: 13px; }
.conversation-exports a { padding: 5px 9px; border: 1px solid #c9ccd1; border-radius: 5px; color: #303236; text-decoration: none; font-size: 13px; }

@media (max-width: 700px) {
    .detail-controls {
        align-items: flex-start;
        flex-direction: column;
    }

    .detail-conversation-pagination {
        margin-top: 0;
    }
}


/* ---------------------------------------------------------
   MESSAGES
--------------------------------------------------------- */

.message {
    max-width: 950px;

    margin: 0 auto 18px;

    border-radius: 8px;

    overflow: hidden;

    border: 1px solid #dedfe2;

    background: #ffffff;
}

.message.user {
    background: #ffffff;
}

.message.assistant {
    background: #f0f1f3;
}

.message-header {
    min-height: 42px;

    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;

    padding: 9px 14px;

    border-bottom: 1px solid #e1e2e4;

    font-size: 11px;
    font-weight: 600;

    color: #74777c;
}

.message-role {
    flex-shrink: 0;

    padding-top: 3px;

    text-transform: uppercase;
    letter-spacing: 0.05em;

    color: #74777c;
}

.message-content {
    padding: 15px 16px;

    font-size: 14px;
    line-height: 1.65;

    color: #202124;

    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.message-content p,
.message-content li,
.message-content blockquote,
.message-content td,
.message-content th,
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4,
.message-content strong,
.message-content em {
    color: #202124;
}

.message-content a {
    color: #315f8c;
}


/* ---------------------------------------------------------
   EMPTY STATE
--------------------------------------------------------- */

.empty-state {
    height: 100%;

    display: flex;
    flex-direction: column;

    align-items: center;
    justify-content: center;

    color: #85888d;
}

.empty-title {
    font-size: 22px;
    font-weight: 600;

    color: #55585d;
}
.notes-empty-state {
    flex: 1;

    display: flex;
    flex-direction: column;

    align-items: center;
    justify-content: center;

    color: #85888d;

    text-align: center;
}

.notes-empty-title {
    font-size: 22px;
    font-weight: 600;

    color: #55585d;
}

.notes-empty-text {
    margin-top: 4px;

    font-size: 14px;

    color: #85888d;
}

.empty-text {
    margin-top: 8px;

    font-size: 13px;
}


/* ---------------------------------------------------------
   RESPONSIVE
--------------------------------------------------------- */

@media (max-width: 900px) {

    .sidebar {
        width: 200px;
    }

    .conversation-panel {
        width: 320px;
    }

    .search-container input {
        width: 220px;
    }
}

@media (max-width: 700px) {

.main {
    width: 100%;
    min-width: 0;
    margin-left: 0;
}
    .sidebar {
        display: none;
    }

    .conversation-panel {
        width: 100%;
    }

    .detail-panel {
        display: none;
    }

    .search-container input {
        width: 180px;
    }
}

/* ---------------------------------------------------------
   HEADER ACTIONS
--------------------------------------------------------- */

.header-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.settings-button {
    padding: 9px 13px;

    border: 1px solid #c9ccd1;
    border-radius: 6px;

    background: #ffffff;
    color: #303236;

    cursor: pointer;
}

.settings-button:hover {
    background: #f0f1f2;
}


/* ---------------------------------------------------------
   AUTH / DIALOGS
--------------------------------------------------------- */

.hidden {
    display: none !important;
}

.overlay,
.auth-overlay {
    position: fixed;

    inset: 0;

    z-index: 1000;

    display: flex;
    align-items: center;
    justify-content: center;

    background: rgba(32, 33, 36, 0.58);
}

.auth-dialog,
.settings-dialog {
    width: 420px;
    max-width: calc(100vw - 40px);

    background: #ffffff;

    border-radius: 8px;

    box-shadow:
        0 12px 40px rgba(0, 0, 0, 0.22);

    padding: 28px;
}

.auth-title {
    font-size: 20px;
    font-weight: 600;
}

.auth-subtitle {
    margin-top: 5px;

    color: #777b80;

    font-size: 13px;
}

.auth-dialog form {
    margin-top: 24px;
}

.auth-dialog label,
.settings-section label {
    display: block;

    margin-bottom: 6px;

    font-size: 13px;
    font-weight: 600;
}

.auth-dialog input,
.settings-section input {
    width: 100%;

    padding: 10px 11px;

    margin-bottom: 14px;

    border: 1px solid #c9ccd1;
    border-radius: 6px;

    background: #ffffff;

    outline: none;
}

.auth-dialog input:focus,
.settings-section input:focus {
    border-color: #777b82;
}

.primary-button {
    width: 100%;

    padding: 10px 14px;

    border: 0;
    border-radius: 6px;

    background: #303236;
    color: #ffffff;

    cursor: pointer;
}

.primary-button:hover {
    background: #202124;
}

.auth-error {
    min-height: 20px;

    margin-top: 12px;

    color: #b3261e;

    font-size: 13px;
}


/* ---------------------------------------------------------
   SETTINGS
--------------------------------------------------------- */

.settings-dialog {
    max-height: calc(100vh - 40px);

    overflow-y: auto;
}

.settings-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;

    margin-bottom: 8px;
}

.dialog-close,
.settings-close {
    width: 32px;
    height: 32px;

    border: 0;
    border-radius: 6px;

    background: transparent;

    font-size: 24px;
    line-height: 1;

    color: #777b80;

    cursor: pointer;
}

.dialog-close:hover,
.settings-close:hover {
    background: #f0f1f2;
}

.settings-project-list {
    display: flex;
    flex-direction: column;

    margin-top: 16px;

    border: 1px solid #dfe1e5;
    border-radius: 6px;

    overflow: hidden;
}

.settings-project-item {
    display: flex;
    align-items: center;

    gap: 10px;

    padding: 11px 12px;

    border-bottom: 1px solid #e5e6e8;

    background: #ffffff;

    cursor: pointer;

    font-size: 14px;
}

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

.settings-project-item:hover {
    background: #f7f8f9;
}

.settings-project-item input {
    width: auto;

    margin: 0;

    cursor: pointer;
}

.settings-loading,
.settings-empty {
    padding: 14px;

    color: #777b80;

    font-size: 13px;
}

.settings-section {
    margin-top: 26px;

    padding-top: 22px;

    border-top: 1px solid #e5e6e8;
}

.settings-section h3 {
    margin: 0 0 7px;

    font-size: 15px;
}

.settings-section p {
    margin: 0 0 16px;

    color: #777b80;

    font-size: 13px;
    line-height: 1.5;
}

.settings-project-list {
    margin-top: 16px;

    border: 1px solid #e1e3e6;
    border-radius: 6px;

    background: #ffffff;

    overflow: hidden;
}


.settings-project-item {
    display: flex;
    align-items: center;
    gap: 12px;

    min-height: 46px;

    padding: 9px 12px;

    border-bottom: 1px solid #e5e6e8;

    cursor: pointer;
}


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


.settings-project-item:hover {
    background: #f6f7f8;
}


.settings-project-item input[type="checkbox"] {
    width: 17px;
    height: 17px;

    margin: 0;

    flex-shrink: 0;

    cursor: pointer;
}


.settings-project-name {
    flex: 1;

    font-size: 14px;
    color: #303236;
}


.settings-project-status {
    font-size: 12px;

    color: #777b80;

    white-space: nowrap;
}

.settings-project-delete {
    padding: 4px 7px;

    border: 1px solid #d9a4a1;
    border-radius: 4px;

    background: #ffffff;
    color: #a2332f;

    cursor: pointer;
    font-size: 12px;
}

.settings-project-delete:hover {
    background: #fff3f2;
}
.settings-project-edit { margin-left:auto; padding:4px 7px; border:1px solid #9eb5d2; border-radius:4px; background:#fff; color:#174f8b; cursor:pointer; font-size:12px; }
.settings-project-edit, .settings-project-delete { width:28px; height:28px; padding:0; display:inline-flex; align-items:center; justify-content:center; }
.settings-project-delete { margin-left:6px; }
.settings-project-status { margin-right: auto; }
.settings-project-edit { margin-left: 0 !important; }

/* Project rows must keep their action icons aligned even for long names. */
.settings-project-item {
    display: grid !important;
    grid-template-columns: 18px minmax(0, 1fr) auto 28px 28px;
    align-items: center;
}

.settings-project-name {
    min-width: 0;
}

.settings-project-status {
    margin-right: 0;
    white-space: nowrap;
}


.settings-project-loading,
.settings-project-empty {
    padding: 16px;

    font-size: 13px;

    color: #777b80;
}

.data-source-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    margin-top: 1rem;
}

.data-source-item {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.8rem;
    border: 1px solid #d8e0ea;
    border-radius: 6px;
    background: #fff;
}

.data-source-details {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
}

.data-source-details span {
    color: #64748b;
    font-size: 0.78rem;
    margin-top: 0.2rem;
}

.data-source-button {
    width: auto;
    margin: 0;
    padding: 0.5rem 0.7rem;
}

.data-sources-panel { flex:1; overflow:auto; padding:32px 40px; }
.data-sources-header { display:flex; justify-content:space-between; align-items:flex-start; gap:20px; }
.data-sources-header h2 { margin:0 0 6px; }
.data-sources-header p { margin:0; color:#64748b; }
.data-sources-header .primary-button { width:auto; margin:0; }
.data-sources-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(300px,1fr)); gap:16px; margin-top:24px; }
.source-card { border:1px solid #d8e0ea; background:#fff; border-radius:8px; padding:18px; }
.source-card-head { display:flex; justify-content:space-between; gap:12px; }
.source-card small,.source-card-meta { color:#64748b; }
.source-card-actions { display:flex; flex-wrap:wrap; gap:8px; margin-top:16px; }
.source-card-actions button { width:auto; margin:0; }
.data-source-editor { max-width:720px; margin-top:24px; border:1px solid #d8e0ea; border-radius:8px; padding:22px; background:#fff; }
.data-source-editor label { display:block; margin:10px 0 4px; }
.data-source-editor input,.data-source-editor select { width:100%; box-sizing:border-box; }
.data-source-editor .source-check { display:flex; align-items:center; gap:7px; }
.data-source-editor .source-check input { width:auto; }
.source-mail-fields { display:block; margin-top:8px; max-width:560px; }
.data-source-editor fieldset { margin:16px 0; border:1px solid #d8e0ea; border-radius:6px; }
.source-check { display:flex; align-items:center; gap:8px; margin:8px 0; }
.source-check input { width:auto; margin:0; }
.source-folder-heading,.source-editor-actions { display:flex; justify-content:space-between; align-items:center; gap:10px; }
.source-folder-heading button,.source-editor-actions button { width:auto; }
.source-folder-list { margin:10px 0; }
.source-folder-options { display:grid; grid-template-columns:repeat(auto-fit,minmax(180px,1fr)); gap:7px; padding:10px; border:1px solid #d8e0ea; border-radius:6px; max-height:240px; overflow:auto; }
.source-folder-options label { display:flex; gap:7px; align-items:center; font-size:.9rem; }
.source-folder-options input { width:auto; margin:0; }
.data-source-editor.mail-source-editor .source-folder-options { display:flex; flex-direction:column; max-height:340px; }
.data-source-editor.mail-source-editor .source-folder-options label { margin:0; padding:5px 4px; border-bottom:1px solid #edf0f3; }

@media (max-width: 700px) {
    .data-source-item { flex-wrap: wrap; }
    .data-source-details { flex-basis: 100%; }
}

.settings-project-list {
    margin-top: 16px;

    border: 1px solid #e1e3e6;
    border-radius: 6px;

    background: #ffffff;

    overflow: hidden;
}


.settings-project-item {
    display: flex;
    align-items: center;
    gap: 12px;

    min-height: 46px;

    padding: 9px 12px;

    border-bottom: 1px solid #e5e6e8;

    cursor: pointer;
}


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


.settings-project-item:hover {
    background: #f6f7f8;
}


.settings-project-item input[type="checkbox"] {
    width: 17px;
    height: 17px;

    margin: 0;

    flex-shrink: 0;

    cursor: pointer;
}


.settings-project-name {
    flex: 1;

    font-size: 14px;
    color: #303236;
}


.settings-project-status {
    font-size: 12px;

    color: #777b80;

    white-space: nowrap;
}


.settings-project-loading,
.settings-project-empty {
    padding: 16px;

    font-size: 13px;

    color: #777b80;
}
.secondary-button,
.logout-button {
    width: 100%;

    padding: 9px 12px;

    margin-top: 8px;

    border-radius: 6px;

    cursor: pointer;
}

.secondary-button {
    border: 1px solid #c9ccd1;

    background: #ffffff;
    color: #303236;
}

.secondary-button:hover {
    background: #f0f1f2;
}

.logout-button {
    border: 1px solid #c94b45;

    background: #ffffff;
    color: #b3261e;
}

.logout-button:hover {
    background: #fff3f2;
}

.settings-message {
    min-height: 20px;

    margin-top: 10px;

    font-size: 13px;
}

.logo-link {
    display: block;

    color: inherit;
    text-decoration: none;
}

.logo-link:hover {
    color: #ffffff;
}

/* ---------------------------------------------------------
   Markdown content
--------------------------------------------------------- */

.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4 {
    margin-top: 1.2em;
    margin-bottom: 0.5em;
}

.message-content h1:first-child,
.message-content h2:first-child,
.message-content h3:first-child,
.message-content h4:first-child {
    margin-top: 0;
}

.message-content p {
    margin: 0.7em 0;
}

.message-content ul,
.message-content ol {
    margin: 0.7em 0;
    padding-left: 1.8em;
}

.message-content li {
    margin: 0.25em 0;
}

.message-content blockquote {
    margin: 1em 0;
    padding-left: 1em;
    border-left: 3px solid #ccc;
    color: #555;
}

.message-content pre {
    overflow-x: auto;
    padding: 1em;
    margin: 1em 0;
    background: #f4f4f4;
    border-radius: 4px;
}

.message-content code {
    font-family:
        "SFMono-Regular",
        Consolas,
        "Liberation Mono",
        monospace;
}

.message-content :not(pre) > code {
    padding: 0.15em 0.3em;
    background: #f0f0f0;
    border-radius: 3px;
}

.message-content table {
    border-collapse: collapse;
    margin: 1em 0;
    width: 100%;
}

.message-content th,
.message-content td {
    border: 1px solid #ccc;
    padding: 0.45em 0.65em;
    text-align: left;
}

.message-content th {
    font-weight: 600;
}

.message-content a {
    text-decoration: underline;
}


/* ---------------------------------------------------------
   ATTACHMENTS
--------------------------------------------------------- */

.message-attachments {
    display: flex;

    flex-direction: column;
    align-items: flex-end;

    gap: 3px;

    max-width: 70%;

    margin-left: auto;

    text-align: right;
}


.message-attachment {
    display: flex;

    align-items: baseline;
    justify-content: flex-end;

    gap: 7px;

    line-height: 1.35;
}


.message-attachment-info {
    display: flex;

    align-items: baseline;

    gap: 6px;

    max-width: 100%;
}


.message-attachment-filename {
    font-size: 11px;
    font-weight: 600;

    color: #3f4348;

    overflow-wrap: anywhere;
}


.message-attachment-meta {
    font-size: 10px;
    font-weight: 400;

    color: #85888d;

    white-space: nowrap;
}


.message-attachment-status {
    font-size: 10px;
    font-weight: 500;

    white-space: nowrap;
}


.message-attachment-status.available {
    color: #4d7a55;
}


.message-attachment-status.missing {
    color: #a33f3f;
}

.message-content pre {
    color: #202124;

    background: #f5f5f6;

    border: 1px solid #e1e2e4;
    border-radius: 6px;

    padding: 12px 14px;

    overflow-x: auto;
}


.message-content code {
    color: #202124;
}


.message-content :not(pre) > code {
    background: #f0f1f2;

    padding: 2px 5px;

    border-radius: 4px;

    color: #202124;
}

/* ---------------------------------------------------------
   Import
--------------------------------------------------------- */

.import-panel {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    padding: 32px 40px;
    box-sizing: border-box;
    background: #fff;
}

.import-header {
    max-width: 900px;
    margin-bottom: 32px;
}

.import-header h2 {
    margin: 0 0 8px 0;
    font-size: 24px;
    font-weight: 600;
}

.import-header p {
    margin: 0;
    color: #666;
    font-size: 14px;
}

.import-section {
    max-width: 900px;
    margin-bottom: 36px;
}

.import-section label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 600;
}

#import-file {
    display: block;
    width: 100%;
    max-width: 700px;
    box-sizing: border-box;
    margin-bottom: 14px;
    padding: 10px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    background: #fff;
    font-size: 14px;
}

#import-button {
    padding: 10px 18px;
    border: 0;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    background: #222;
    color: #fff;
}

#import-button:hover {
    background: #444;
}

.import-message {
    max-width: 900px;
    margin-bottom: 32px;
    min-height: 20px;
}

.import-section h3 {
    margin: 0 0 16px 0;
    font-size: 18px;
    font-weight: 600;
}

.import-archive-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 900px;
}

.import-archive-item {
    padding: 16px 18px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background: #fff;
}

.import-archive-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 20px;
    margin-bottom: 8px;
}

.import-archive-header strong {
    font-size: 15px;
    font-weight: 600;
    text-transform: capitalize;
}

.import-archive-header span {
    color: #777;
    font-size: 13px;
    white-space: nowrap;
}

.import-archive-filename {
    margin-bottom: 6px;
    font-size: 14px;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.import-archive-meta {
    color: #777;
    font-size: 13px;
}

.import-preview-item {
    max-width: 900px;
    margin-bottom: 12px;
    padding: 16px 18px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background: #fff;
    line-height: 1.5;
}

.import-preview-item strong {
    display: block;
    margin-bottom: 6px;
    font-size: 15px;
}

.import-preview-item > div {
    margin-top: 4px;
    color: #555;
}

.import-message > h3 {
    margin: 0 0 16px 0;
}

#import-confirm-button {
    margin-top: 8px;
    padding: 10px 18px;
    border: 0;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    background: #222;
    color: #fff;
}

#import-confirm-button:hover {
    background: #444;
}

/* ---------------------------------------------------------
   Import result
--------------------------------------------------------- */

.import-result {
    max-width: 900px;
    margin-bottom: 32px;
    padding: 20px;
    border: 1px solid #d8d8d8;
    border-radius: 5px;
    background: #fff;
}

.import-result-header {
    margin-bottom: 24px;
}

.import-result-header h3 {
    margin: 0 0 6px 0;
    font-size: 20px;
    font-weight: 600;
}

.import-result-header p {
    margin: 0;
    color: #666;
    font-size: 14px;
    overflow-wrap: anywhere;
}

.import-result-summary {
    display: grid;
    grid-template-columns:
        repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin-bottom: 28px;
}

.import-result-stat {
    padding: 14px;
    border: 1px solid #e1e1e1;
    border-radius: 4px;
    background: #f8f8f8;
}

.import-result-stat strong {
    display: block;
    margin-bottom: 4px;
    font-size: 20px;
    font-weight: 600;
}

.import-result-stat span {
    display: block;
    color: #666;
    font-size: 13px;
    line-height: 1.35;
}

.import-result-files {
    margin-bottom: 24px;
}

.import-result-files h4 {
    margin: 0 0 12px 0;
    font-size: 15px;
    font-weight: 600;
}

.import-result-file {
    padding: 12px 14px;
    border-top: 1px solid #e5e5e5;
}

.import-result-file strong {
    display: block;
    margin-bottom: 4px;
    font-size: 14px;
}

.import-result-file-meta {
    margin-top: 4px;
    color: #777;
    font-size: 13px;
}

.import-result-archive {
    padding-top: 16px;
    border-top: 1px solid #ddd;
    font-size: 13px;
}

.import-result-archive strong {
    display: block;
    margin-bottom: 4px;
    font-size: 14px;
}

.import-result-archive div {
    color: #666;
    overflow-wrap: anywhere;
}

.import-error {
    max-width: 900px;
    padding: 14px 16px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    background: #f8f8f8;
}

/* ---------------------------------------------------------
   MOBILE OPTIMIZATION
--------------------------------------------------------- */

@media (max-width: 700px) {

    body {
        overflow-x: hidden;
    }

    .main {
        width: 100%;
        min-width: 0;
    }

    .header {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 12px 14px;
    }

    .header-title {
        font-size: 22px;
        line-height: 1.2;
    }

    .header-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        width: 100%;
    }

    .header-actions select,
    .header-actions input,
    .header-actions button {
        box-sizing: border-box;
        min-height: 42px;
    }

    .header-actions select {
        flex: 1 1 calc(50% - 4px);
        min-width: 0;
    }

    .search-container {
        display: flex;
        flex: 1 1 100%;
        width: 100%;
    }

    .search-container input {
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }

    .settings-button {
        flex: 0 0 auto;
    }

    .conversation-panel {
        width: 100%;
        min-width: 0;
    }

    .panel-header {
        padding: 14px 16px;
    }

    .conversation-pagination {
        padding: 12px 16px;
        gap: 12px;
        flex-wrap: wrap;
    }

    .conversation-list {
        width: 100%;
    }

    .conversation-item {
        padding: 18px 16px;
    }

    .conversation-title {
        font-size: 18px;
        line-height: 1.3;
    }

    .conversation-meta,
    .conversation-project {
        font-size: 14px;
    }
}

/* ---------------------------------------------------------
   MOBILE NAVIGATION / MOBILE UX
--------------------------------------------------------- */

.mobile-navigation,
.mobile-menu-button {
    display: none;
}

@media (max-width: 700px) {

    /* Mobile navigation bar */

    .mobile-navigation {
        display: flex;
        align-items: center;
        gap: 8px;

        padding: 8px 10px;

        background: #ffffff;
        border-bottom: 1px solid #dfe1e5;

        flex-shrink: 0;
    }

    .mobile-navigation button {
        padding: 8px 12px;

        border: 1px solid #c9ccd1;
        border-radius: 6px;

        background: #ffffff;
        color: #303236;

        cursor: pointer;
    }

    /* Mobile sidebar */

    .sidebar {
        display: none;

        position: fixed;
        z-index: 1000;

        top: 0;
        left: 0;
        bottom: 0;

        width: 280px;

        box-shadow: 4px 0 16px rgba(0, 0, 0, 0.20);
    }

    .sidebar.mobile-visible {
        display: flex;
    }

    /* Main area */

    .main {
        width: 100%;
        min-width: 0;
    }

    .header {
        height: auto;
        min-height: 56px;

        padding: 8px 10px;
    }

    .header-title {
        font-size: 17px;
    }

    .header-actions {
        gap: 6px;
    }

    /*
     * Suche auf Mobilgeräten zunächst ausblenden.
     * Einstellungen bleiben sichtbar.
     */

    .search-container {
        display: none;
    }

    .settings-button {
        display: block;

        padding: 8px 10px;
        font-size: 13px;
    }

    /* Content */

    .content {
        position: relative;
        width: 100%;
        min-width: 0;
    }

    .conversation-panel {
        width: 100%;
        flex: 1;
        min-width: 0;
    }

    .detail-panel {
        display: none;

        width: 100%;
        flex: 1;
        min-width: 0;
    }

    .conversation-panel.mobile-hidden {
        display: none;
    }

    .detail-panel.mobile-visible {
        display: block;
    }

    /*
     * Import und Einstellungen sollen auf Mobilgeräten
     * ebenfalls die gesamte verfügbare Breite verwenden.
     */

    .import-panel {
        width: 100%;
    }

    /*
     * Navigation innerhalb der Sidebar auf dem Telefon
     */

    .navigation {
        flex: 1;
        overflow-y: auto;
    }

}

/* ---------------------------------------------------------
   MOBILE
--------------------------------------------------------- */

@media (max-width: 700px) {

    .mobile-navigation {
        display: flex;
        align-items: center;
        gap: 8px;

        padding: 8px 10px;

        background: #ffffff;
        border-bottom: 1px solid #dfe1e5;
    }

    .mobile-navigation button {
        padding: 8px 12px;

        border: 1px solid #c9ccd1;
        border-radius: 6px;

        background: #ffffff;
        color: #303236;

        cursor: pointer;
    }

    .mobile-navigation button:hover {
        background: #f0f1f2;
    }

    .header {
        height: auto;
        min-height: 56px;

        padding: 8px 10px;
    }

    .header-title {
        font-size: 17px;
    }

    .header-actions {
        gap: 6px;
    }

    .search-container {
        display: none;
    }

    .settings-button {
        padding: 8px 10px;
        font-size: 13px;
    }

    .content {
        position: relative;
    }

    .conversation-panel {
        width: 100%;
        flex: 1;
    }

    .detail-panel {
        display: none;
        width: 100%;
        flex: 1;
    }

    .conversation-panel.mobile-hidden {
        display: none;
    }

    .detail-panel.mobile-visible {
        display: block;
    }

}

.mobile-navigation-close {
    display: none;
}

@media (max-width: 700px) {
    .mobile-navigation-close {
        display: block;
        position: absolute;
        top: 10px;
        right: 10px;
        z-index: 1001;

        padding: 4px 9px;

        border: 1px solid #c9ccd1;
        border-radius: 6px;

        background: #ffffff;
        color: #303236;

        font-size: 22px;
        line-height: 1;
        cursor: pointer;
    }

    .mobile-navigation-close:hover {
        background: #f0f1f2;
    }
}

/* ---------------------------------------------------------
   MOBILE SEARCH
--------------------------------------------------------- */

#mobile-search-button {
    display: none;
}

@media (max-width: 700px) {

    #mobile-search-button {
        display: block;
    }

    .header .search-container.mobile-search-visible {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        width: 100%;
        margin-top: 6px;
    }

    .header .search-container.mobile-search-visible select {
        flex: 1 1 140px;
        min-width: 0;
    }

    .header .search-container.mobile-search-visible input {
        flex: 1 1 180px;
        min-width: 0;
        width: auto;
    }

    .header .search-container.mobile-search-visible button {
        flex: 0 0 auto;
    }
}

.chatgpt-entity {
    color: #315f8c;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 2px;
}

.chatgpt-entity:hover {
    text-decoration-style: solid;
}



/* ---------------------------------------------------------
   NOTIZBLOCK – 3-SPALTEN-LAYOUT
--------------------------------------------------------- */

.notes-panel {
    display: flex;

    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;

    padding: 0;

    background: #f7f7f8;

    overflow: hidden;
}


/* ---------------------------------------------------------
   NOTIZLISTE – entspricht der Gesprächsliste
--------------------------------------------------------- */

.notes-list-panel {
    width: 390px;
    flex-shrink: 0;

    display: flex;
    flex-direction: column;

    min-height: 0;

    background: #ffffff;

    border-right: 1px solid #dfe1e5;
}

.notes-side-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 48px;
    padding: 0 10px 0 16px;
    border-bottom: 1px solid #e4e6e9;
    color: #1e3550;
    font-size: 14px;
}

.notes-panel-toggle {
    width: 30px;
    height: 30px;
    border: 1px solid #c8d2dd;
    border-radius: 5px;
    background: #fff;
    color: #174f8b;
    font-size: 21px;
    line-height: 1;
    cursor: pointer;
}

.notes-panel-toggle:hover,
.notes-panel-toggle:focus-visible {
    background: #edf4fa;
    outline: none;
}

.notes-list-panel.is-collapsed {
    width: 42px;
}

.notes-list-panel.is-collapsed .notes-side-panel-header {
    justify-content: center;
    padding: 0;
}

.notes-list-panel.is-collapsed .notes-side-panel-header strong,
.notes-list-panel.is-collapsed .notes-list {
    display: none;
}

.notes-list {
    flex: 1;
    min-height: 0;

    overflow-y: auto;
}

.notes-list-item {
    display: flex;
    flex-direction: column;

    width: 100%;

    padding: 14px 16px;

    border: 0;
    border-bottom: 1px solid #ececee;

    background: #ffffff;

    color: #303236;

    text-align: left;

    cursor: pointer;
}

.notes-list-item:hover {
    background: #f5f6f7;
}

.notes-list-item.active {
    background: #e9eaec;
}

.notes-folder-row {
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid #ececee;
    background: #fff;
}

.notes-folder-row .notes-list-item {
    border-bottom: 0;
}

.notes-folder-rename,
.notes-folder-action,
.notes-folder-delete {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    align-self: center;
    width: 30px;
    height: 30px;
    flex: 0 0 auto;
    margin: 0 5px 0 0;
    padding: 4px 6px;
    border: 1px solid #c9ccd1;
    border-radius: 4px;
    background: #fff;
    color: #4e5965;
    cursor: pointer;
}

.notes-folder-action {
    margin-left: auto;
    margin-right: 4px;
}

.notes-folder-delete {
    color: #9c3535;
}

.notes-list-title {
    font-size: 14px;
    font-weight: 600;

    line-height: 1.4;
}

.notes-list-meta {
    margin-top: 4px;

    font-size: 11px;

    color: #777b80;
}


/* ---------------------------------------------------------
   NOTIZDETAIL – entspricht dem Gesprächsdetail
--------------------------------------------------------- */

.notes-detail-panel {
    display: flex;
    flex-direction: column;

    flex: 1;
    min-width: 0;
    min-height: 0;

    background: #f7f7f8;

    overflow: hidden;
}

.notes-entities-panel {
    width: 310px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: #fff;
    border-left: 1px solid #dfe1e5;
    overflow: hidden;
}

.notes-entities-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 12px;
}

.notes-semantic-hint {
    margin: 0;
    color: #6d7782;
    font-size: 13px;
    line-height: 1.5;
}

.notes-entity-list {
    display: grid;
    gap: 8px;
}

.notes-entity-chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    padding: 9px 10px;
    border: 1px solid #d6e0eb;
    border-radius: 6px;
    background: #f6f9fc;
    color: #263b51;
    text-align: left;
}

.notes-entity-chip small { color: #637488; }
.notes-entity-chip button { border: 0; background: transparent; color: #8a3b3b; cursor: pointer; font-size: 16px; }

.notes-entity-actions {
    display: grid;
    gap: 8px;
    margin-top: 16px;
}

.notes-entity-actions button {
    min-height: 34px;
    border: 1px solid #b9cce0;
    border-radius: 5px;
    background: #fff;
    color: #174f8b;
    cursor: pointer;
}

.notes-entity-actions button:disabled { color: #929aa3; border-color: #d9dde1; cursor: not-allowed; }

.notes-entities-panel.is-collapsed { width: 42px; }
.notes-entities-panel.is-collapsed .notes-side-panel-header { justify-content: center; padding: 0; }
.notes-entities-panel.is-collapsed .notes-side-panel-header strong,
.notes-entities-panel.is-collapsed .notes-entities-content { display: none; }

/* Gemeinsame rechte Spalte außerhalb des Notizblocks. Sie stellt sicher, dass
   Chats, Medien und Entitäten dieselbe vierte Arbeitsfläche erhalten. */
.workspace-semantic-panel {
    width: 310px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: #fff;
    border-left: 1px solid #dfe1e5;
    overflow: hidden;
}

.workspace-semantic-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 12px;
    color: #6d7782;
    font-size: 13px;
    line-height: 1.5;
}

.workspace-semantic-action {
    width: 100%;
    min-height: 34px;
    margin-top: 16px;
    border: 1px solid #b9cce0;
    border-radius: 5px;
    background: #fff;
    color: #174f8b;
    cursor: pointer;
}

.workspace-semantic-heading {
    display: block;
    margin-top: 20px;
}

.workspace-semantic-context {
    margin-top: 20px;
}

.context-link {
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: #1769aa;
    font: inherit;
    text-decoration: underline;
    cursor: pointer;
}

.context-link:disabled {
    color: #7c8792;
    text-decoration: none;
    cursor: not-allowed;
}

/* Gemeinsamer Inhaltskopf: dieselben Klassen wie das Gesprächsdetail. */
.notes-content-actions .detail-controls {
    margin-top: 12px;
}

.notes-content-actions .conversation-project-assignment {
    margin-top: 0;
}

.notes-project-control {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-top: 0;
}

.notes-project-control select {
    min-width: 180px;
    padding: 5px 8px;
    border: 1px solid #cbd3dc;
    border-radius: 5px;
    background: #fff;
    font: inherit;
}

/* Die Notizkopfzeile verwendet dieselbe rechte Navigation wie Detailansichten. */
.notes-content-actions .detail-conversation-pagination {
    margin-left: auto;
}

.notes-bookmark {
    width: 32px;
    height: 32px;
    min-width: 32px;
    padding: 0;
    margin-left: 8px;
    border: 1px solid #c6ced8;
    border-radius: 4px;
    background: #fff;
    color: #1d5c99;
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
}

.notes-editor-bookmark-row {
    display: flex;
    justify-content: flex-end;
    min-height: 40px;
    padding: 4px 10px 8px;
    border-top: 1px solid #ececee;
}

.notes-bookmark:hover {
    background: #f5f6f7;
}

.notes-pagination {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 46px;
    padding: 8px 18px;
    border-bottom: 1px solid #e5e6e8;
    color: #777b80;
    font-size: 12px;
}

.notes-pagination button {
    padding: 5px 9px;
    border: 1px solid #dfe1e5;
    border-radius: 4px;
    background: #fff;
    color: #44484d;
    font: inherit;
    cursor: pointer;
}

.notes-pagination button:disabled {
    color: #b5b7ba;
    background: #f7f7f8;
    cursor: default;
}

.notes-list-category {
    padding: 12px 16px 7px;
    border-bottom: 1px solid #e5e6e8;
    background: #fff;
    color: #263c58;
    font-size: 13px;
    font-weight: 700;
}

.workspace-semantic-panel.is-collapsed { width: 42px; }
.workspace-semantic-panel.is-collapsed .notes-side-panel-header { justify-content: center; padding: 0; }
.workspace-semantic-panel.is-collapsed .notes-side-panel-header strong,
.workspace-semantic-panel.is-collapsed .workspace-semantic-content { display: none; }

.notes-detail-panel .notes-header {
    flex-shrink: 0;
    width: calc(100% - 64px);
    max-width: 950px;
    margin: 0 auto 28px;
    padding: 24px 0 0;
    background: transparent;
    border: 0;
}

.notes-editor-container {
    display: flex;
    flex-direction: column;

    flex: 1;
    min-width: 0;
    min-height: 0;

    margin: 24px 32px 0;

    border: 1px solid #d7d9dc;
    border-radius: 7px;

    background: #ffffff;

    overflow: hidden;
}


/* ---------------------------------------------------------
   TOOLBAR – bleibt stehen
--------------------------------------------------------- */

.notes-toolbar {
    flex-shrink: 0;

    display: flex;
    align-items: center;
    flex-wrap: wrap;

    gap: 4px;

    padding: 7px 9px;

    border-bottom: 1px solid #e1e2e4;

    background: #f5f6f7;
}

.notes-toolbar button {
    min-width: 32px;
    height: 30px;
    padding: 4px 7px;
    border: 1px solid transparent;
    border-radius: 5px;
    background: transparent;
    color: #344152;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
}

.notes-toolbar button:hover,
.notes-toolbar button:focus-visible {
    border-color: #b7c8dc;
    background: #ffffff;
    color: #174f8b;
    outline: none;
}

.notes-toolbar-separator {
    width: 1px;
    height: 21px;
    margin: 0 3px;
    background: #d6dbe1;
}


/* ---------------------------------------------------------
   EDITOR – einziger Scrollbereich
--------------------------------------------------------- */

.notes-editor {
    flex: 1;

    min-width: 0;
    min-height: 0;

    padding: 24px 28px;

    outline: none;

    overflow-y: auto;

    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    font-size: 15px;
    line-height: 1.65;

    color: #202124;

    background: #ffffff;
}

.notes-editor h1,
.notes-editor h2,
.notes-editor h3 {
    color: #1e3550;
    line-height: 1.25;
}

.notes-editor h1 { font-size: 1.75em; }
.notes-editor h2 { font-size: 1.4em; }
.notes-editor h3 { font-size: 1.15em; }

.notes-editor blockquote {
    margin: 1em 0;
    padding: 8px 14px;
    border-left: 3px solid #6e9ec8;
    background: #f1f6fb;
    color: #43566c;
}

.notes-editor pre {
    padding: 14px;
    overflow-x: auto;
    border-radius: 6px;
    background: #202b38;
    color: #f3f7fb;
}

.notes-editor hr {
    margin: 1.5em 0;
    border: 0;
    border-top: 1px solid #d9dee5;
}

.notes-checklist-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    list-style: none;
}

.notes-checklist-item input { margin-top: 0.35em; }

.notes-markdown-source {
    flex: 1;
    min-width: 0;
    min-height: 0;
    padding: 20px 24px;
    border: 0;
    outline: none;
    resize: none;
    overflow-y: auto;
    background: #202b38;
    color: #edf3f9;
    font: 14px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.notes-status {
    min-height: 20px;
    margin: 8px 32px 16px;
    color: #6d7782;
    font-size: 12px;
}


/* ---------------------------------------------------------
   NOTIZBLOCK – MOBILE
--------------------------------------------------------- */

@media (max-width: 900px) {

    .notes-list-panel {
        width: 320px;
    }

    .notes-entities-panel { width: 270px; }
    .workspace-semantic-panel { width: 270px; }

    .notes-detail-panel .notes-header {
        padding-left: 20px;
        padding-right: 20px;
    }

    .notes-editor-container {
        margin-left: 20px;
        margin-right: 20px;
    }
}

@media (max-width: 700px) {

    .notes-panel {
        display: block;

        overflow: auto;
    }

    .notes-list-panel {
        width: 100%;
        height: 220px;
    }

    .notes-list-panel.is-collapsed,
    .notes-entities-panel.is-collapsed { width: 100%; height: 42px; }

    .notes-entities-panel {
        width: 100%;
        min-height: 180px;
        border-left: 0;
        border-top: 1px solid #dfe1e5;
    }

    .workspace-semantic-panel {
        width: 100%;
        min-height: 160px;
        border-left: 0;
        border-top: 1px solid #dfe1e5;
    }

    .workspace-semantic-panel.is-collapsed { width: 100%; height: 42px; min-height: 42px; }

    .notes-detail-panel {
        height: calc(100% - 220px);
    }

    .notes-detail-panel .notes-header {
        padding: 14px;
    }

    .notes-editor-container {
        margin: 12px 14px 0;
    }

    .notes-editor {
        padding: 18px;
    }
}

.notes-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.notes-list-header button {
    padding: 5px 9px;

    border: 1px solid #d5d7da;
    border-radius: 5px;

    background: #ffffff;
    color: #303236;

    font-size: 12px;

    cursor: pointer;
}

.notes-list-header button:hover {
    background: #f3f4f5;
}

.notes-list-item.hidden {
    display: none;
}

.notes-list-file-row {
    display: flex;

    width: 100%;

    border-bottom: 1px solid #ececee;

    background: #ffffff;
}

.notes-list-file-row:hover {
    background: #f5f6f7;
}

.notes-list-file-row .notes-list-item {
    flex: 1;

    min-width: 0;

    border-bottom: 0;
}

.notes-delete-button {
    flex: 0 0 42px;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 0;

    border: 0;

    background: transparent;

    color: #777b80;

    font-size: 14px;

    cursor: pointer;
}

.notes-delete-button:hover {
    color: #b33;
    background: #f0f1f2;
}

.data-source-log-panel {
    width: 100%;
    max-width: none;
    box-sizing: border-box;
    margin: 20px 0;
    padding: 16px 20px;
    border: 1px solid #d9dee5;
    border-radius: 8px;
    background: #fff;
}

.data-sources-log {
    display: grid;
    gap: 8px;
    max-height: 420px;
    overflow: auto;
    color: #627087;
    font-size: 13px;
}

.data-source-log-view { display:grid; grid-template-columns:minmax(260px, 1fr) minmax(280px, 1.25fr); gap:12px; align-items:start; }
.data-source-log-view .data-sources-log { max-height:520px; overflow:auto; }
.data-source-log-entry { display:block; width:100%; text-align:left; border:1px solid #d7dee8; border-radius:6px; padding:10px 12px; margin:0 0 8px; background:#fff; cursor:pointer; font:inherit; }

.data-source-log-entry > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: #26364d; }
.data-source-log-entry p { margin: 4px 0 0; }
.data-source-log-status { font-size: 12px; font-weight: 600; }
.data-source-log-status.success { color: #287640; }
.data-source-log-status.partial { color: #9a6911; }
.data-source-log-status.failed { color: #b23b3b; }
.data-source-log-error { color: #9c3434; white-space: pre-wrap; }

.resource-metadata {
    display: grid;
    grid-template-columns: minmax(92px, 1fr) minmax(0, 2fr);
    gap: 4px 10px;
    margin: 7px 0 12px;
    color: #627087;
    font-size: 12px;
}

.resource-metadata dt { font-weight: 600; color: #46566d; }
.resource-metadata dd { margin: 0; overflow-wrap: anywhere; }

/* Typed archive records: a message and a calendar entry are not files with
   unusual MIME types, but readable archival objects with their own context. */
.email-record, .calendar-record {
    max-width: 980px;
    padding: 1.35rem 1.5rem;
    background: #fff;
    border: 1px solid #d8dee7;
    border-radius: 8px;
    box-sizing: border-box;
}
.email-record-header, .calendar-record-metadata {
    display: grid;
    grid-template-columns: 7rem minmax(0, 1fr);
    gap: .45rem .85rem;
    margin: 0 0 1.25rem;
    padding-bottom: 1.1rem;
    border-bottom: 1px solid #e3e8ee;
}
.email-record-header dt, .calendar-record-metadata dt {
    font-weight: 600;
    color: #56657a;
}
.email-record-header dd, .calendar-record-metadata dd { margin: 0; overflow-wrap: anywhere; }
.email-record-body, .calendar-record-description {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    line-height: 1.58;
}
.email-record h3 { font-size: .94rem; margin: 1.5rem 0 .55rem; color: #34435a; }
.email-contact-list { display: flex; flex-wrap: wrap; gap: .45rem; }
.email-contact {
    padding: .35rem .65rem;
    border: 1px solid #b9c9dc;
    border-radius: 999px;
    background: #f4f8fc;
    color: #234b75;
    cursor: pointer;
}
.email-contact:hover { background: #e7f0f9; }
.calendar-record-kind {
    display: inline-block;
    margin: 0 0 1rem;
    padding: .22rem .55rem;
    border-radius: 999px;
    background: #eaf2ee;
    color: #286044;
    font-size: .82rem;
    font-weight: 600;
}
.resource-reference-list { display: grid; gap: 6px; margin: 7px 0; }
.resource-reference { display: flex; align-items: center; gap: 6px; }
.resource-reference a, .resource-reference button:first-child { flex: 1; overflow: hidden; text-align: left; text-overflow: ellipsis; white-space: nowrap; }
.resource-reference button:last-child { color: #a33; }

.data-source-log-entry > span:first-child { display:flex; justify-content:space-between; gap:12px; align-items:center; }
.data-source-log-entry.active { border-color:#668daf; background:#edf4fa; }
.data-source-log-detail { min-height:230px; padding:12px 16px; border:1px solid #d7dee8; border-radius:6px; background:#f8fafc; color:#26364d; }
.data-source-log-detail h4 { margin:0 0 8px; }
.data-source-log-detail dl { display:grid; grid-template-columns:max-content 1fr; gap:8px 16px; margin:12px 0; }
.data-source-log-detail dt { font-weight:600; }
.data-source-log-detail dd { margin:0; }
@media (max-width: 760px) { .data-source-log-view { grid-template-columns:1fr; } }
.data-source-log-note { margin:12px 0 0; padding:10px 12px; border-left:3px solid #668daf; background:#eef5fb; white-space:pre-wrap; }
.note-embedded-image { display:block; max-width:100%; height:auto; margin:12px 0; border:1px solid #d8e0ea; border-radius:6px; }
.workspace-shared-context { margin-top:16px; padding-top:12px; border-top:1px solid #d8e0ea; }
.workspace-shared-context > a { display:block; margin:10px 0; color:#275d8c; }

/* Lokale/externe Chats im gemeinsamen Vier-Spalten-Raster. */
.local-model-label { display:flex; align-items:center; gap:6px; }
.local-messages { display:flex; flex-direction:column; gap:14px; max-height:calc(100vh - 390px); min-height:280px; overflow:auto; padding:12px 0; }
.message-card { border:1px solid #d9dee6; border-radius:8px; padding:14px 16px; background:#f5f6f8; }
.message-card.user { background:#fff; }
.message-card strong { font-size:12px; color:#64748b; text-transform:uppercase; letter-spacing:.04em; }
.message-card p { white-space:normal; line-height:1.5; }
.local-compose { border-top:1px solid #d9dee6; padding-top:14px; display:flex; gap:10px; align-items:end; }
.local-compose textarea { flex:1; min-height:80px; resize:vertical; }

.navigation a.nav-item { text-decoration:none; }
.local-chat-toolbar { display:flex; align-items:center; gap:8px; margin-top:12px; color:#64748b; font-size:13px; }
.message-card-head { display:flex; align-items:center; gap:10px; margin-bottom:10px; }
.message-card-head small { color:#7c8796; font-size:12px; }
.message-copy { margin-left:auto; font-size:12px; padding:3px 8px; }
.message-markdown { line-height:1.6; }
.message-markdown h1,.message-markdown h2,.message-markdown h3 { margin:12px 0 8px; }
.local-compose button { min-width:82px; }

.local-chat-item { display:flex; align-items:center; gap:8px; padding:14px 12px 14px 16px; }
.local-chat-open { min-width:0; flex:1; padding:0; border:0; background:transparent; color:inherit; text-align:left; cursor:pointer; }
.local-chat-open .conversation-title,.local-chat-open .conversation-meta { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.local-chat-actions { display:flex; flex:0 0 auto; gap:5px; }
.local-chat-delete,.local-chat-rename { width:28px; height:28px; padding:0; border:1px solid #c6ced8; border-radius:4px; background:#fff; cursor:pointer; }
.local-chat-delete { color:#a33; } .local-chat-rename { color:#1d5c99; }

.local-chat-toolbar { color:#718096; } .local-chat-toolbar button { color:#1f2937; }
.local-chat-pagination { margin-left:auto; color:#94a3b8; letter-spacing:2px; }
.message-card-head .message-favorite { margin-left:auto; border:0; background:transparent; font-size:17px; }
.message-card .message-copy { margin-top:8px; }
.settings-dialog { width: min(670px, calc(100vw - 40px)); }
#settings-models-list label { display:flex; align-items:center; gap:8px; min-height:32px; }

.settings-project-item { display:flex !important; align-items:center !important; gap:8px; }
.settings-project-item .settings-project-name { margin-right:auto !important; text-align:left; }
.settings-project-item .settings-project-status { margin-left:10px; margin-right:auto !important; }
.settings-project-item .settings-project-edit,.settings-project-item .settings-project-delete { flex:0 0 28px; margin:0 !important; }
#settings-models-list .settings-project-item { justify-content:flex-start; }

/* Aktive Chats: identisches Kartenverhalten wie im Archiv. */
.conversation-item strong { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.local-messages .message-card { position:relative; margin-bottom:30px; }
.local-messages .message-card .message-copy { position:absolute; left:0; bottom:-27px; margin:0; border:0; background:transparent; color:#64748b; padding:2px 0; font-size:12px; }
.local-messages .message-card .message-copy:hover { color:#1d4f91; text-decoration:underline; }


/* Stabile Zeilenraster der Einstellungen – keine Umbrüche der Bedienelemente. */
#settings-models-list .settings-model-item {
  display:grid !important; grid-template-columns:20px minmax(0, 1fr) 28px 28px;
  align-items:center; gap:8px; width:100%; min-height:42px; box-sizing:border-box;
}
#settings-models-list .settings-model-item .settings-project-name {
  margin:0 !important; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; text-align:left;
}
#settings-models-list .settings-model-item .settings-project-edit,
#settings-models-list .settings-model-item .settings-project-delete { margin:0 !important; width:28px; height:28px; }
#settings-project-list .settings-project-item {
  display:grid !important; grid-template-columns:20px minmax(0, 1fr) auto 28px 28px 28px;
  grid-template-rows:1fr !important; align-items:center; gap:8px; width:100%; box-sizing:border-box;
}
#settings-project-list .settings-project-item .settings-project-name {
  margin:0 !important; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; text-align:left;
}
#settings-project-list .settings-project-item .settings-project-status { margin:0 !important; white-space:nowrap; }
#settings-project-list .settings-project-item .settings-project-edit,
#settings-project-list .settings-project-item .settings-project-delete { margin:0 !important; width:28px; height:28px; }
#settings-data-source-list .settings-source-item {
  display:grid !important; grid-template-columns:minmax(0, 1fr) 28px; align-items:center; gap:8px; width:100%; box-sizing:border-box;
}
#settings-data-source-list .settings-source-item .settings-project-name {
  margin:0 !important; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; text-align:left;
}
#settings-data-source-list .settings-source-item .settings-project-delete { margin:0 !important; width:28px; height:28px; }


/* Aktive Chats nutzen das Gerüst und die Klassen der archivierten Gespräche. */
.local-messages .local-message-wrap { max-width:950px; margin:0 auto 18px; }
.local-messages .message { max-width:none; margin:0; }
.local-messages .message-header small { margin-left:0; color:#7c8796; font-size:12px; font-weight:400; }
.local-messages .message-bookmark { margin-left:auto; border:0; background:transparent; cursor:pointer; font-size:17px; }
.local-messages .message-copy { display:block; margin:7px 0 0; padding:0; border:0; background:transparent; color:#64748b; font-size:12px; cursor:pointer; }
.local-messages .message-copy:hover { color:#1d4f91; text-decoration:underline; }


.context-picker-overlay { position:fixed; inset:0; z-index:300; display:flex; align-items:center; justify-content:center; padding:24px; background:rgba(20,28,38,.45); }
.context-picker-dialog { width:min(760px,100%); max-height:min(720px,calc(100vh - 48px)); display:flex; flex-direction:column; gap:14px; padding:22px; overflow:hidden; border-radius:8px; background:#fff; box-shadow:0 16px 42px rgba(0,0,0,.28); }
.context-picker-dialog h3 { margin:0; }
.context-picker-controls { display:grid; grid-template-columns:170px minmax(0,1fr) 180px; gap:8px; }
.context-picker-controls select,.context-picker-controls input { min-width:0; padding:8px; border:1px solid #c9d1dc; border-radius:4px; }
.context-picker-results { min-height:180px; max-height:420px; overflow:auto; border:1px solid #d8dde4; border-radius:6px; }
.context-picker-row { display:grid; grid-template-columns:24px minmax(0,1fr) 130px; gap:8px; align-items:center; padding:10px 12px; border-bottom:1px solid #e7eaee; cursor:pointer; }
.context-picker-row:last-child { border-bottom:0; }
.context-picker-row span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.context-picker-row small { color:#6d7782; text-align:right; }
.context-picker-footer { display:flex; justify-content:flex-end; gap:8px; }
@media(max-width:700px) { .context-picker-controls { grid-template-columns:1fr; } .context-picker-row { grid-template-columns:24px minmax(0,1fr); } .context-picker-row small { grid-column:2; text-align:left; } }

.context-reference-row { display:flex; align-items:center; gap:6px; margin:7px 0; min-width:0; }
.context-reference-row span,.context-reference-row a { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.context-reference-delete { margin-left:auto; width:28px; height:28px; border:1px solid #e2a3a3; border-radius:4px; background:#fff; color:#b42e2e; cursor:pointer; }
.context-reference-delete:hover { background:#fff2f2; }
.context-picker-controls { grid-template-columns:150px 150px minmax(0,1fr) 160px; }


/* Virtuelle Medienansichten: keine Dateien oder Ordner werden verschoben. */
.media-view-tree { display:flex; align-items:center; gap:6px; flex-wrap:wrap; margin:0 0 10px; padding:8px; border:1px solid #d9e0e8; border-radius:6px; background:#fff; }
.media-view-tree strong { margin-right:4px; color:#526174; font-size:12px; text-transform:uppercase; letter-spacing:.03em; }
.media-view-button { padding:5px 8px; border:1px solid transparent; border-radius:4px; background:transparent; color:#34445a; cursor:pointer; }
.media-view-button:hover { background:#eef4fb; }
.media-view-button.active { border-color:#9bb8db; background:#e7f0fb; color:#164b85; font-weight:600; }
