:root {
    --ml-ink: #1c2430;
    --ml-muted: #5b6775;
    --ml-surface: #f3f6f9;
    --ml-accent: #1f6f8b;
    --ml-accent-dark: #18586d;
    --ml-panel: #d9e6ec;
    --ml-chat-bg: #e8eef2;
    --ml-bubble-own: #d6ebf2;
    --ml-bubble-other: #ffffff;
    --ml-chat-border: rgba(28, 36, 48, 0.1);
}

body {
    color: var(--ml-ink);
    background: linear-gradient(180deg, #f8fafc 0%, #eef3f7 100%);
    font-family: "Source Sans 3", "Segoe UI", sans-serif;
}

.navbar-brand {
    letter-spacing: 0.02em;
}

.public-body .hero-panel {
    background:
        radial-gradient(circle at top right, rgba(31, 111, 139, 0.12), transparent 42%),
        linear-gradient(135deg, #f8fafc 0%, #e7eef3 100%);
}

.hero-visual {
    background: var(--ml-panel);
    border: 1px solid rgba(28, 36, 48, 0.08);
}

.btn-primary {
    background-color: var(--ml-accent);
    border-color: var(--ml-accent);
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--ml-accent-dark);
    border-color: var(--ml-accent-dark);
}

.btn-outline-primary {
    color: var(--ml-accent);
    border-color: var(--ml-accent);
}

.btn-outline-primary:hover,
.btn-outline-primary:focus {
    background-color: var(--ml-accent);
    border-color: var(--ml-accent);
}

.private-body {
    background: #f5f7fa;
}

.tracking-wide {
    letter-spacing: 0.08em;
}

/* Conversation modal */
.conversation-modal .conversation-dialog {
    width: min(420px, 100%);
    max-width: 420px;
    margin: 1rem auto;
}

.conversation-shell {
    height: min(720px, calc(100vh - 2rem));
    display: flex;
    flex-direction: column;
    border: 0;
    overflow: hidden;
    background: var(--ml-chat-bg);
}

.conversation-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    background: #f7fafc;
    border-bottom: 1px solid var(--ml-chat-border);
}

.conversation-messages-wrap {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
}

.conversation-messages {
    height: 100%;
    overflow-y: auto;
    padding: 0.85rem 0.75rem 1rem;
    scroll-behavior: auto;
}

.new-messages-btn {
    position: absolute;
    left: 50%;
    bottom: 0.75rem;
    transform: translateX(-50%);
    z-index: 2;
    border-radius: 999px;
    padding: 0.35rem 0.9rem;
}

.msg-date-sep {
    display: flex;
    justify-content: center;
    margin: 0.65rem 0;
}

.msg-date-sep span {
    background: rgba(28, 36, 48, 0.08);
    color: var(--ml-muted);
    font-size: 0.75rem;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
}

.msg-row {
    display: flex;
    margin-bottom: 0.35rem;
}

.msg-row.is-own {
    justify-content: flex-end;
}

.msg-row.is-other {
    justify-content: flex-start;
}

.msg-bubble {
    max-width: min(78%, 320px);
    border-radius: 0.85rem;
    padding: 0.45rem 0.65rem 0.35rem;
    box-shadow: 0 1px 1px rgba(28, 36, 48, 0.06);
    position: relative;
}

.msg-row.is-own .msg-bubble {
    background: var(--ml-bubble-own);
    border-top-right-radius: 0.25rem;
}

.msg-row.is-other .msg-bubble {
    background: var(--ml-bubble-other);
    border-top-left-radius: 0.25rem;
}

.msg-reply-ref {
    border-left: 3px solid var(--ml-accent);
    background: rgba(28, 36, 48, 0.05);
    border-radius: 0.35rem;
    padding: 0.25rem 0.45rem;
    margin-bottom: 0.35rem;
    font-size: 0.78rem;
    color: var(--ml-muted);
    white-space: pre-wrap;
    word-break: break-word;
}

.msg-body {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.95rem;
    line-height: 1.35;
}

.msg-meta {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.2rem;
    font-size: 0.7rem;
    color: var(--ml-muted);
}

.msg-actions {
    margin-top: 0.15rem;
}

.msg-reply-btn,
.msg-react-btn {
    font-size: 0.7rem;
    padding: 0;
    color: var(--ml-accent);
}

.msg-react-btn {
    margin-left: 0.55rem;
}

.msg-bubble-media {
    background: transparent !important;
    box-shadow: none;
    padding: 0.15rem 0.25rem;
    max-width: min(78%, 260px);
}

.msg-image,
.msg-gif {
    display: block;
    max-width: 220px;
    max-height: 280px;
    width: auto;
    height: auto;
    border-radius: 0.65rem;
    object-fit: contain;
}

.msg-sticker {
    display: block;
    max-width: 140px;
    max-height: 140px;
    width: auto;
    height: auto;
    object-fit: contain;
    background: transparent;
}

.msg-media-btn {
    border: 0;
    background: transparent;
    padding: 0;
    display: block;
}

.msg-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem;
    margin-top: 0.2rem;
}

.msg-reaction {
    background: rgba(28, 36, 48, 0.06);
    border-radius: 999px;
    padding: 0.05rem 0.35rem;
    font-size: 0.85rem;
    line-height: 1.2;
}

.msg-reaction.is-mine {
    outline: 1px solid rgba(31, 111, 139, 0.45);
}

.composer-icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 999px;
    padding: 0;
    flex: 0 0 auto;
    line-height: 1;
}

.media-picker {
    background: #f7fafc;
    border-top: 1px solid var(--ml-chat-border);
    max-height: 220px;
    display: flex;
    flex-direction: column;
}

.media-picker-body {
    overflow-y: auto;
    padding: 0.5rem;
}

.picker-pane {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.picker-emoji-btn {
    font-size: 1.35rem;
    line-height: 1;
    padding: 0.25rem 0.4rem;
}

.picker-asset-btn {
    width: 72px;
    height: 72px;
    padding: 0.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.picker-asset-btn img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.reaction-picker-choices {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    justify-content: center;
}

.reaction-choice {
    font-size: 1.4rem;
    line-height: 1;
    padding: 0.35rem 0.5rem;
}

.reply-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 0.85rem;
    background: #f7fafc;
    border-top: 1px solid var(--ml-chat-border);
}

.reply-preview-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ml-accent);
}

.reply-preview-text {
    font-size: 0.85rem;
    color: var(--ml-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 280px;
}

.conversation-composer {
    display: flex;
    align-items: flex-end;
    gap: 0.35rem;
    padding: 0.65rem 0.75rem;
    background: #f7fafc;
    border-top: 1px solid var(--ml-chat-border);
}

.message-input {
    resize: none;
    max-height: 120px;
    min-height: 40px;
    border-radius: 1rem;
}

.send-btn {
    border-radius: 999px;
    padding-inline: 1rem;
    flex: 0 0 auto;
}

.conversation-empty {
    text-align: center;
    color: var(--ml-muted);
    font-size: 0.9rem;
    padding: 2rem 1rem;
}

@media (max-width: 575.98px) {
    .conversation-modal .modal-dialog.conversation-dialog {
        width: 100%;
        max-width: 100%;
        margin: 0;
        height: 100%;
    }

    .conversation-modal .modal-content.conversation-shell {
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
    }

    .conversation-modal.show .modal-dialog {
        transform: none;
    }
}

/* Private / Health */
.private-container {
    max-width: 860px;
}

.health-panel {
    background: #fff;
    border: 1px solid rgba(28, 36, 48, 0.08);
    border-radius: 0.85rem;
    padding: 1rem;
}

.health-summary-card {
    background: #fff;
    border: 1px solid rgba(28, 36, 48, 0.08);
    border-radius: 0.85rem;
    padding: 0.75rem 0.65rem;
    text-align: center;
    height: 100%;
}

.health-summary-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ml-muted);
    margin-bottom: 0.25rem;
}

.health-summary-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--ml-ink);
    word-break: break-word;
}

.health-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.health-entry {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
    justify-content: space-between;
    padding: 0.85rem 0.75rem;
    border: 1px solid rgba(28, 36, 48, 0.08);
    border-radius: 0.75rem;
    background: #fafbfc;
}

.health-entry-main {
    min-width: 0;
    flex: 1 1 auto;
}

.health-entry-when {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-bottom: 0.35rem;
    font-size: 0.82rem;
    color: var(--ml-muted);
}

.health-entry-date {
    font-weight: 600;
    color: var(--ml-ink);
}

.health-entry-values {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.health-metric {
    font-size: 0.98rem;
    font-weight: 550;
}

.health-metric .unit {
    font-size: 0.78rem;
    color: var(--ml-muted);
    font-weight: 500;
}

.health-entry-notes {
    margin-top: 0.4rem;
    font-size: 0.88rem;
    color: var(--ml-muted);
    white-space: pre-wrap;
    word-break: break-word;
}

.health-entry-menu {
    line-height: 1;
    padding: 0.15rem 0.45rem;
}

.health-empty {
    padding: 1.25rem 0.25rem;
}

.chart-box {
    position: relative;
    height: 220px;
}

.dashboard-recent-item + .dashboard-recent-item {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(28, 36, 48, 0.08);
}

.dashboard-recent-title {
    font-weight: 550;
    font-size: 0.95rem;
}

.dashboard-recent-meta {
    font-size: 0.8rem;
}

.quick-add-btn {
    min-width: 6.5rem;
}

/* Notes */
.note-pin-badge {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--ml-ink);
    background: rgba(28, 36, 48, 0.08);
    border-radius: 0.35rem;
    padding: 0.12rem 0.4rem;
}

.note-entry-pinned {
    border-color: rgba(28, 36, 48, 0.18);
}

.note-body-preview,
.note-body-field {
    white-space: pre-wrap;
    word-break: break-word;
}

/* Important dates */
.date-section + .date-section {
    margin-top: 0;
}

/* Custom logs */
.logs-category-list {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.logs-category-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
    width: 100%;
    text-align: left;
    padding: 0.75rem 0.85rem;
    border: 1px solid rgba(28, 36, 48, 0.08);
    border-radius: 0.75rem;
    background: #fafbfc;
    color: inherit;
}

.logs-category-card.is-selected {
    border-color: rgba(31, 111, 139, 0.45);
    background: rgba(31, 111, 139, 0.06);
}

.logs-category-card.is-inactive {
    opacity: 0.7;
}

.logs-category-name {
    font-weight: 600;
    font-size: 0.95rem;
    word-break: break-word;
}

.logs-category-meta {
    font-size: 0.78rem;
}

.logs-fields-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.logs-field-chip {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    max-width: 100%;
    padding: 0.35rem 0.45rem 0.35rem 0.65rem;
    border: 1px solid rgba(28, 36, 48, 0.08);
    border-radius: 0.65rem;
    background: #fafbfc;
    font-size: 0.85rem;
}

.logs-field-chip-name {
    font-weight: 550;
}

.logs-field-chip-type {
    color: var(--ml-muted);
    font-size: 0.75rem;
}

@media (min-width: 768px) {
    .logs-layout {
        display: grid;
        grid-template-columns: minmax(0, 14rem) minmax(0, 1fr);
        gap: 1rem;
        align-items: start;
    }

    .logs-layout > .health-panel:first-child {
        margin-bottom: 0 !important;
    }

    .logs-layout > #logsDetail,
    .logs-layout > #logsNoSelection {
        grid-column: 2;
        grid-row: 1 / span 2;
    }
}

@media (max-width: 575.98px) {
    .private-body .container.private-container {
        padding-left: 0.85rem;
        padding-right: 0.85rem;
    }

    .health-summary-value {
        font-size: 0.92rem;
    }

    .chart-box {
        height: 200px;
    }
}

/* Public calculators */
.calc-card {
    padding: 1.15rem 1.2rem;
    border: 1px solid rgba(28, 36, 48, 0.1);
    border-radius: 0.85rem;
    background: linear-gradient(165deg, #fff 0%, #f7f9fb 100%);
    color: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.calc-card:hover {
    border-color: rgba(31, 111, 139, 0.35);
    box-shadow: 0 0.35rem 1rem rgba(28, 36, 48, 0.06);
}

.calc-panel,
.calc-results {
    padding: 1.1rem 1.15rem;
    border: 1px solid rgba(28, 36, 48, 0.1);
    border-radius: 0.85rem;
    background: #fff;
}

.calc-result-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    padding: 0.55rem 0;
    border-bottom: 1px solid rgba(28, 36, 48, 0.06);
    font-size: 0.95rem;
}

.calc-result-row:last-child {
    border-bottom: 0;
}

.calc-result-row strong {
    text-align: right;
    word-break: break-word;
}
