[hidden] {
    display: none !important;
}

.chat-login-window,
.chat-shell {
    background: #c0c0c0;
    border: 2px solid #808080;
    box-shadow: 3px 3px 0 #404040;
}

.portfolio-content p.chat-login-intro {
    text-align: center;
    max-width: 520px;
    margin: 0 auto 16px;
}

.chat-login-window {
    max-width: 520px;
    margin: 16px auto 24px;
}

.chat-login-title,
.chat-thread-title,
.chat-inbox-title {
    background: linear-gradient(90deg, #000080, #1084d0);
    color: #fff;
    font-weight: bold;
    font-size: 14px;
    padding: 6px 8px;
}

.chat-login-form {
    background: #ffffe0;
    padding: 14px;
}

.chat-greeting-box {
    background: #e6f0fa;
    border: 2px inset #808080;
    padding: 10px 12px;
    margin-bottom: 12px;
}

.chat-greeting-title {
    font-size: 15px;
    font-weight: bold;
    color: #000080;
    margin-bottom: 4px;
}

.chat-greeting-text {
    font-size: 13px;
    color: #333333;
}

.chat-new-user-box {
    background: #e8f8e8;
    border: 1px dashed #008000;
    color: #006400;
    font-size: 13px;
    font-weight: bold;
    padding: 8px 10px;
    margin-bottom: 12px;
}

.chat-login-form input[type="text"],
.chat-login-form input[type="email"] {
    width: 98%;
    border: 1px inset #000;
    padding: 6px;
    font-size: 15px;
}

.chat-field-error,
.chat-login-status {
    display: block;
    margin-top: 6px;
    color: #800000;
    font-weight: bold;
}

.chat-login-status.ok {
    color: #006400;
}

.chat-dev-code {
    background: #000;
    color: #00ff00;
    font-family: "Courier New", monospace;
    padding: 8px;
}

.chat-shell {
    display: flex;
    min-height: 520px;
    margin: 12px 0 20px;
}

.chat-shell-admin .chat-inbox {
    width: 280px;
    border-right: 2px solid #808080;
    background: #d4d0c8;
    display: flex;
    flex-direction: column;
}

.chat-inbox-list {
    overflow-y: auto;
    flex: 1;
}

.chat-inbox-item {
    display: block;
    width: 100%;
    text-align: left;
    background: #d4d0c8;
    border: 0;
    border-bottom: 1px solid #808080;
    padding: 8px;
    cursor: pointer;
    font-family: "MS Sans Serif", sans-serif;
}

.chat-inbox-item:hover,
.chat-inbox-item.active {
    background: #000080;
    color: #fff;
}

.chat-inbox-name {
    display: block;
    font-weight: bold;
}

.chat-inbox-email,
.chat-inbox-preview,
.chat-inbox-meta {
    display: block;
    font-size: 12px;
    opacity: 0.9;
}

.chat-inbox-preview {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-unread {
    background: #ff0000;
    color: #fff;
    border-radius: 8px;
    padding: 0 6px;
    margin-left: 6px;
}

.chat-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
    background: #808080;
}

.chat-dot.online,
.chat-presence.online {
    color: #006400;
}

.chat-dot.online {
    background: #00c000;
}

.chat-dot.offline {
    background: #808080;
}

.chat-thread {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: #fff;
}

.chat-thread-title {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.chat-presence,
.chat-conn {
    font-size: 12px;
    font-weight: normal;
}

.chat-conn {
    margin-left: auto;
}

.chat-thread-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    position: relative;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 12px 20px;
    background: #ffffff;
    min-height: 280px;
    max-height: 420px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scroll-behavior: auto;
}

.chat-thread-loader {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(192, 192, 192, 0.82);
}

.chat-thread-loader-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #000080;
    color: #fff;
    border: 2px inset #c0c0c0;
    padding: 12px 16px;
    font-weight: bold;
}

.chat-empty {
    color: #808080;
    text-align: center;
    padding: 24px 8px;
}

.chat-bubble {
    max-width: 80%;
    margin: 0;
    padding: 8px 10px;
    border: 1px solid #808080;
    align-self: flex-start;
}

.chat-bubble.mine {
    align-self: flex-end;
    background: #dce8ff;
}

.chat-bubble.theirs {
    align-self: flex-start;
    background: #ffffc8;
}

.chat-bubble-meta {
    font-size: 11px;
    color: #404040;
    margin-bottom: 4px;
}

.chat-bubble-body {
    white-space: pre-wrap;
    word-break: break-word;
}

.chat-read {
    font-size: 11px;
    color: #404040;
}

.chat-read.is-read {
    color: #000080;
}

.chat-typing {
    padding: 8px 12px;
    background: #ffffe0;
    border-top: 1px dashed #808080;
    clear: both;
}

.chat-typing-label {
    font-size: 12px;
    font-style: italic;
    color: #404040;
    margin-bottom: 4px;
}

.chat-typing-text {
    white-space: pre-wrap;
    word-break: break-word;
    background: #ffffc8;
    border: 1px dashed #808080;
    padding: 6px 8px;
    min-height: 1.2em;
}

.chat-bubble.pending {
    opacity: 0.85;
}

.chat-inbox-item.typing .chat-inbox-preview {
    color: #000080;
    font-style: italic;
}

.chat-composer {
    flex-shrink: 0;
    border-top: 2px solid #808080;
    padding: 8px;
    background: #c0c0c0;
}

.chat-composer textarea:disabled,
.chat-composer button:disabled {
    opacity: 0.7;
}

.chat-composer textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px inset #000;
    min-height: 56px;
    font-size: 15px;
    resize: vertical;
}

.chat-composer-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-count,
.chat-load-older {
    font-size: 12px;
}

.chat-load-older {
    background: #c0c0c0;
    border: 1px outset #c0c0c0;
    margin: 6px auto;
    display: block;
    cursor: pointer;
}

.chat-logout-row {
    margin-top: 8px;
}

.chat-logout-top {
    margin-top: 0;
    margin-bottom: 8px;
}

.chat-verify-loader {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #000080;
    color: #fff;
    border: 2px inset #c0c0c0;
    padding: 10px 12px;
    margin: 8px 0;
    font-weight: bold;
}

.chat-verify-spinner {
    width: 18px;
    height: 18px;
    border: 3px solid #808080;
    border-top-color: #ffff00;
    border-radius: 50%;
    animation: chat-spin 0.8s linear infinite;
    flex-shrink: 0;
}

.chat-history-loader {
    text-align: center;
    font-size: 12px;
    color: #404040;
    background: #ffffe0;
    border-bottom: 1px dashed #808080;
    padding: 6px 8px;
}

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

.chat-launcher {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 1200;
    background: #000080;
    color: #fff;
    text-decoration: none;
    border: 2px outset #c0c0c0;
    padding: 10px 14px;
    font-weight: bold;
    box-shadow: 3px 3px 0 #000;
}

.chat-launcher:hover {
    background: #0000ff;
    color: #ffff00;
}

.chat-clearfix::after {
    content: "";
    display: block;
    clear: both;
}

/* ---- AI assistant ---- */

.chat-bubble.ai {
    background: #e8ffe8;
    border-color: #008000;
    box-shadow: inset 3px 0 0 #00a000;
}

.chat-bubble.mine.ai {
    background: #e0f4e0;
}

.chat-bubble.local {
    border-style: dashed;
}

.chat-ai-badge {
    display: inline-block;
    background: #006400;
    color: #fff;
    font-size: 10px;
    font-weight: bold;
    padding: 0 4px;
    border: 1px outset #c0c0c0;
}

.chat-ai-beta {
    margin: 0 0 6px;
    padding: 4px 8px;
    background: #fff8c4;
    border: 1px solid #8a5a00;
    font-size: 12px;
}

.chat-ai-beta[hidden] {
    display: none;
}

.chat-bubble-body a {
    color: #0000ee;
    text-decoration: underline;
    word-break: break-all;
}

.chat-notice {
    align-self: center;
    max-width: 90%;
    text-align: center;
    font-size: 12px;
    color: #404040;
}

.chat-notice span {
    display: inline-block;
    background: #ececec;
    border: 1px dashed #808080;
    padding: 3px 10px;
}

.chat-assistant-bar,
.chat-ai-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 6px 10px;
    background: #d4d0c8;
    border-bottom: 1px solid #808080;
    font-size: 13px;
}

.chat-assistant-bar.is-ai {
    background: #e8ffe8;
}

.chat-assistant-state,
.chat-ai-mode-label {
    flex: 1;
    min-width: 180px;
    font-weight: bold;
}

.chat-handoff-btn,
.chat-ai-controls .retro-btn {
    font-size: 12px;
    padding: 3px 8px;
}

.chat-ai-controls .retro-btn:disabled {
    opacity: 0.55;
    cursor: default;
}

.chat-handoff-banner {
    padding: 6px 10px;
    font-size: 13px;
    border-bottom: 1px solid #808080;
    background: #ffffe0;
}

.chat-handoff-banner.waiting {
    background: #fff4c0;
    animation: chat-pulse 1.6s ease-in-out infinite;
}

.chat-handoff-banner.accepted {
    background: #d8ffd8;
    font-weight: bold;
}

.chat-handoff-banner.declined {
    background: #ffe4e4;
}

@keyframes chat-pulse {
    50% {
        background: #ffe680;
    }
}

.chat-ai-typing {
    padding: 4px 12px;
    font-size: 12px;
    font-style: italic;
    color: #006400;
    background: #f4fff4;
    border-top: 1px dashed #808080;
}

.chat-dots i {
    display: inline-block;
    width: 4px;
    height: 4px;
    margin-left: 2px;
    background: #006400;
    border-radius: 50%;
    animation: chat-blink 1.2s infinite;
}

.chat-dots i:nth-child(2) {
    animation-delay: 0.2s;
}

.chat-dots i:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes chat-blink {
    0%, 80%, 100% {
        opacity: 0.2;
    }

    40% {
        opacity: 1;
    }
}

.chat-starters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 10px;
    background: #f4f4f4;
    border-top: 1px dashed #808080;
}

.chat-starter {
    background: #c0c0c0;
    border: 2px outset #ffffff;
    font-size: 12px;
    padding: 3px 8px;
    cursor: pointer;
}

.chat-starter:hover {
    background: #000080;
    color: #fff;
}

.chat-starter:active {
    border-style: inset;
}

.chat-summary {
    padding: 4px 10px;
    background: #fffff0;
    border-bottom: 1px solid #808080;
    font-size: 12px;
}

.chat-summary summary {
    cursor: pointer;
    font-weight: bold;
}

.chat-summary-text {
    white-space: pre-line;
    padding: 6px 0;
    max-height: 160px;
    overflow-y: auto;
}

.chat-inbox-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: -4px;
}

.chat-inbox-mode {
    font-size: 12px;
}

.chat-briefing {
    align-self: stretch;
    background: #fffbe6;
    border: 2px dashed #b08000;
    padding: 8px 10px;
    font-size: 13px;
}

.chat-briefing-title {
    font-weight: bold;
    color: #805000;
    margin-bottom: 6px;
}

.chat-briefing-private {
    float: right;
    font-weight: normal;
    font-size: 11px;
    color: #404040;
}

.chat-briefing-body {
    white-space: pre-wrap;
    word-break: break-word;
}

.chat-briefing-pending {
    align-self: center;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #805000;
    background: #fffbe6;
    border: 1px dashed #b08000;
    padding: 6px 10px;
}

/* ---- Handoff page (emailed link) ---- */

.chat-handoff-window {
    max-width: 620px;
    margin: 16px auto 24px;
    background: #c0c0c0;
    border: 2px solid #808080;
    box-shadow: 3px 3px 0 #404040;
}

.chat-handoff-title {
    background: linear-gradient(90deg, #000080, #1084d0);
    color: #fff;
    font-weight: bold;
    padding: 6px 8px;
}

.chat-handoff-body {
    background: #fff;
    margin: 4px;
    padding: 14px 16px;
}

.chat-handoff-body h2 {
    margin-top: 0;
    font-size: 20px;
    color: #000080;
}

.chat-handoff-meta {
    font-size: 13px;
}

.chat-handoff-countdown {
    font-family: "Courier New", monospace;
    font-weight: bold;
    background: #000;
    color: #00ff00;
    padding: 1px 6px;
}

.chat-handoff-countdown.urgent {
    color: #ff4040;
}

.chat-handoff-flash {
    background: #ffff80;
    border: 1px solid #000;
    padding: 6px 8px;
}

.chat-handoff-summary,
.chat-handoff-recent {
    background: #f4f4f4;
    border: 1px inset #808080;
    padding: 8px 10px;
    margin: 10px 0;
    font-size: 13px;
}

.chat-handoff-summary p {
    white-space: pre-line;
    margin: 4px 0 0;
}

.chat-handoff-line {
    margin-top: 4px;
}

.chat-handoff-line .who {
    font-weight: bold;
    color: #000080;
}

.chat-handoff-line.visitor .who {
    color: #800000;
}

.chat-handoff-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 14px;
}

.chat-handoff-accept {
    font-size: 16px;
    padding: 10px;
    font-weight: bold;
}

.chat-handoff-decline {
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-top: 1px dashed #808080;
    padding-top: 10px;
}

.chat-handoff-decline textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px inset #000;
    font-size: 14px;
}

.chat-handoff-decline .retro-btn {
    align-self: flex-start;
}

@media (max-width: 760px) {
    .chat-shell-admin {
        flex-direction: column;
        min-height: 0;
    }

    .chat-shell-admin .chat-inbox {
        width: 100%;
        max-height: 180px;
        border-right: 0;
        border-bottom: 2px solid #808080;
    }

    .chat-messages {
        max-height: 320px;
    }
}
