html {
  font-size: 16px;
  scroll-behavior: smooth;
  overscroll-behavior: none;
}
/* html.dynamic-font-embed {
  font-size: clamp(16px, 1.05vw, 18px);
} */

body {
    font-family: "Inter", sans-serif;
    background-color: #f8f9fa;
    /* All scrolling happens inside #chat-container / overlays; locking the body
       stops iOS from panning the page (and losing the header) when the
       on-screen keyboard opens. */
    overflow: hidden;
    overscroll-behavior: none;
}

.plotly-notifier {
    display: none !important;
}

.form-control {
    font-size: 1rem !important;
}
.fs-9 {
    font-size: 0.625rem !important;
}
.fs-10 {
    font-size: 0.625rem !important;
}
.fs-11 {
    font-size: 0.75rem !important;
}
.fs-12 {
    font-size: 0.75rem !important;
}
.fs-13 {
    font-size: 0.8rem !important;
}
.fs-14 {
    font-size: 0.875rem !important;
}

/* Table Export */
.table-export-wrapper {
    position: relative;
    margin-top: 0.5rem;
    margin-bottom: 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}
.table-scroll-container {
    overflow-x: auto;
    max-width: 100%;
    width: 100%;
    padding-bottom: 4px;
}
.table-scroll-container::-webkit-scrollbar {
    height: 4px;
}
.table-scroll-container::-webkit-scrollbar-track {
    background: rgba(var(--color-primary-rgb), 0.08);
    border-radius: 4px;
    margin: 0 4px;
}
.table-scroll-container::-webkit-scrollbar-thumb {
    background: rgba(var(--color-primary-rgb), 0.5);
    border-radius: 4px;
    transition: background 200ms ease;
}
.table-scroll-container::-webkit-scrollbar-thumb:hover {
    background: rgba(var(--color-primary-rgb), 0.8);
}
html[data-theme='dark'] .table-scroll-container::-webkit-scrollbar-track {
    background: rgba(var(--color-primary-rgb), 0.1);
}
html[data-theme='dark'] .table-scroll-container::-webkit-scrollbar-thumb {
    background: rgba(var(--color-primary-rgb), 0.5);
}
html[data-theme='dark'] .table-scroll-container::-webkit-scrollbar-thumb:hover {
    background: rgba(var(--color-primary-rgb), 0.8);
}
.table-scroll-container table {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    width: max-content !important;
    min-width: 100%;
}
.table-export-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 0.25rem 0.6rem;
    margin-top: 0.25rem;
    border-radius: 0.4rem;
    border: 1px solid rgba(2,6,23,0.1);
    background: #fff;
    color: #475569;
    font-size: 0.7rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 200ms ease, border-color 200ms ease, color 200ms ease, transform 200ms ease, box-shadow 200ms ease;
}
.table-export-wrapper:hover .table-export-btn {
    opacity: 1;
}
.table-export-btn:hover {
    background: #f1f5f9;
    border-color: var(--color-primary);
    color: var(--color-primary);
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0,162,197,0.15);
}
.table-export-btn:active {
    transform: scale(0.95);
}
.table-export-btn.exported {
    background: var(--color-secondary);
    border-color: var(--color-secondary);
    color: #fff;
}
html[data-theme='dark'] .table-export-btn {
    background: rgba(255,255,255,0.08);
    border-color: rgba(148,163,184,0.3);
    color: #e2e8f0;
}
html[data-theme='dark'] .table-export-btn:hover {
    background: rgba(0,162,197,0.15);
    border-color: var(--color-primary);
    color: var(--color-primary);
    box-shadow: 0 2px 8px rgba(0,162,197,0.3);
}
html[data-theme='dark'] .table-export-btn.exported {
    background: var(--color-secondary);
    border-color: var(--color-secondary);
    color: #fff;
}

/* Light mode Table */
/* Light mode Table */
.bot-message-bubble table,
table {
    font-size: 0.8rem;
    width: 100%;
    border-spacing: 0;
    border-collapse: separate;
    margin-top: 0.5rem;
    margin-bottom: 0.75rem;
    border: none;
    border-radius: 0.5rem;
    overflow: hidden;
}
table thead {
    background: rgba(var(--color-primary-rgb), 0.75);
}
table th {
    font-weight: 600;
    color: #fff;
    padding: 0.55rem 0.75rem;
    text-align: left;
    vertical-align: middle;
    border: none;
}
table td {
    padding: 0.5rem 0.75rem;
    text-align: left;
    vertical-align: middle;
    border: none;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
}
table tbody tr:last-child td {
    border-bottom: none;
}
table tbody tr:nth-child(odd) {
    background: #fff;
}
table tbody tr:nth-child(even) {
    background: #f8fafc;
}
table tbody tr:hover {
    background: rgba(0,162,197,0.05);
}
/* Dark mode Table */
html[data-theme='dark'] table {
    border-color: #334155;
}
html[data-theme='dark'] table thead {
    background: rgba(var(--color-primary-rgb), 0.75);
}
html[data-theme='dark'] table th {
    color: #fff;
}
html[data-theme='dark'] table td {
    color: #e2e8f0;
    border-bottom-color: #1e293b;
}
html[data-theme='dark'] table tbody tr:nth-child(odd) {
    background: #0f172a;
}
html[data-theme='dark'] table tbody tr:nth-child(even) {
    background: #1e293b;
}
html[data-theme='dark'] table tbody tr:hover {
    background: rgba(0,162,197,0.12);
}
#chat-window {
    /* --kb-inset: on-screen keyboard overlap, set by setupKeyboardViewportHandler()
       (index.js) on iOS, where the keyboard never shrinks the layout viewport.
       Android shrinks dvh itself via interactive-widget=resizes-content. */
    height: calc(100vh - var(--kb-inset, 0px));
    height: calc(100dvh - var(--kb-inset, 0px));
    display: flex;
    align-items: center;
    justify-content: center;
}

#chat-card {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
#chat-card.standalone {
    max-width: 60vw;
    max-height: 99vh;
    max-height: 99dvh;
    margin-left: auto;
    margin-right: auto;
}
@media screen and (max-width: 768px) {
    #chat-card {
        max-width: unset !important;
        max-height: unset !important;
    }
    .hero-input-group .form-control.user-input {
        font-size: 1rem;
    }
    .hero-input-group .form-control.user-input::placeholder {
        color: #94a3b8;
    }
}
@media screen and (min-width: 1024px) {
    #chat-container {
        padding-inline: 10vw !important;
    }
    .input-box {
        margin-inline: 10vw !important;
    }
}

#chat-container {
    flex-grow: 1;
    scroll-behavior: smooth;
    /* Reserve room for the floating glass dock so the last message clears it.
       !important is needed to beat Bootstrap's .p-4 (padding:1.5rem !important). */
    padding-bottom: 7rem !important;
    /* Clear the now-floating glass header so the first message starts below it
       (messages still scroll up under it and blur through). */
    padding-top: 5rem !important;
}
/* Floating dock: overlays the bottom of the chat so the glass blurs the
   conversation scrolling behind it. Only the bar/tip capture pointer events. */
.input-dock {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5;
    pointer-events: none;
}
.input-dock > * { pointer-events: auto; }
/* Fade scrim: messages dissolve into the page background toward the very
   bottom so the tip stays legible. Kept low/soft so the glass bar (which sits
   above the opaque zone) still blurs live messages behind it. */
.input-dock::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(100% + 20px);
    background: linear-gradient(
        to top,
        rgba(248,249,250,0.96) 0%,
        rgba(248,249,250,0.9) 18%,
        rgba(248,249,250,0) 52%
    );
    pointer-events: none;
    z-index: -1;
}
html[data-theme='dark'] .input-dock::before {
    background: linear-gradient(
        to top,
        rgba(15,23,42,0.96) 0%,
        rgba(15,23,42,0.9) 18%,
        rgba(15,23,42,0) 52%
    );
}
#chat-card.hero-active .input-dock { display: none; }
#hero-input {
    max-height: 120px;
    /* Overflow is managed by setupAutoResize(): hidden while the content fits,
       auto once it exceeds max height. A CSS `!important` here would override
       that inline toggle and force a scrollbar even for the wrapped placeholder. */
    overflow-y: hidden;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    line-height: 1.4;
}
/* Hero overlay - initial screen */
.hero-overlay {
    position: absolute;
    inset: 56px 0 0 0; /* leave header space */
    display: flex;
    align-items: safe center;
    justify-content: center;
    overflow-y: auto;
    pointer-events: none;
    opacity: 0;
    transition: opacity 220ms ease;
    z-index: 10;
}
.hero-overlay .hero-content { pointer-events: none; }
#chat-card.hero-active .hero-overlay {
    opacity: 1;
    pointer-events: auto;
}
#chat-card.hero-active .hero-overlay .hero-content {
    pointer-events: auto;
}
.hero-content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    max-width: 680px;
    width: 100%;
    padding-bottom: 2rem;
}
/* Hero icon with glow */
.hero-icon-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
}
.hero-icon-glow {
    position: absolute;
    inset: 6px;
    border-radius: 50%;
    box-shadow: 0 0 8px 2px rgba(0,162,197,0.35);
    animation: pulseGlow 3s ease-in-out infinite;
}
@keyframes pulseGlow {
    0%, 100% { transform: scale(1); opacity: 0.85; }
    50% { transform: scale(1.15); opacity: 1; }
}
.hero-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    position: relative;
    z-index: 1;
}
/* Hero heading */
.hero-heading {
    font-size: clamp(20px, 2.5vw, 26px);
    font-weight: 600;
    color: #0f172a;
    margin: 0;
    margin-top: -0.75rem;
}
/* Hero description */
.hero-description {
    font-size: clamp(13px, 1.4vw, 15px);
    color: #64748b;
    line-height: 1.5;
    /* Even out wrapped lines so the sub line doesn't orphan a single word
       (e.g. "trends.") on its own row. */
    text-wrap: balance;
}
/* Two-line hierarchy: a larger, medium-weight lead line over a smaller,
   lighter supporting line. */
.hero-desc-lead {
    font-size: clamp(15px, 1.7vw, 18px);
    font-weight: 500;
    color: #94a3b8;
}
.hero-desc-sub {
    font-size: clamp(12px, 1.3vw, 14px);
    color: #94a3b8;
}
/* On short viewports, vertical centering pushes the glowing icon up under the
   header where it gets clipped (and `align-items: safe center` isn't honored by
   every webview). Anchor the content to the top and tighten it so the icon and
   glow stay fully visible, with the overlay scrolling if needed. */
@media (max-height: 720px) {
    .hero-overlay { align-items: flex-start; }
    .hero-content { padding-top: 1.25rem; padding-bottom: 1.25rem; gap: 0.75rem; }
}
@media (max-height: 560px) {
    .hero-icon-wrapper { width: 56px; height: 56px; }
    .hero-icon { width: 44px; height: 44px; }
}

/* Hero input wrapper - no longer absolute */
.hero-input-wrapper {
    width: min(600px, 92vw);
    display: flex;
    flex-direction: column;
}
.hero-input-group {
    width: 100%;
    align-items: flex-end;
    background: #ffffff;
    border-radius: 2rem;
    border: 1px solid rgba(2,6,23,0.1);
    padding: 0.25rem;
    box-shadow: 0 2px 8px rgba(2,6,23,0.04);
    transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
.hero-input-group:focus-within {
    border-color: rgba(0,162,197,0.4);
    box-shadow: 0 2px 12px rgba(0,162,197,0.1);
    background: #fff;
}
html.embed-false #hero-brand-title .brand-orbit { display: inline; }
.hero-input-group .form-control.user-input {
    background: transparent;
    border-radius: 1.5rem !important;
    resize: none; /* auto-resize via JS */
    overflow-y: auto;
    scrollbar-gutter: stable both-edges; /* keep scrollbar space inside */
    background-clip: padding-box;
    border: none !important;
    box-shadow: none !important;
    /* Fixed line box (1.5rem) + symmetric padding so a single line fills the
       40px min-height exactly and stays vertically centered — independent of
       the reduced placeholder font (a shorter line box would leave a bottom
       gap and push the text up). */
    line-height: 1.5rem;
    padding-block: 0.5rem;
}
.hero-input-group .form-control.user-input::placeholder {
    color: #94a3b8;
}
/* Smaller font only while the placeholder is showing (reverts to normal size
   once the user types). Applied to the element — not ::placeholder — so the JS
   width measurement in fitPlaceholder reads the reduced size and truncates the
   hero prompt to one line with a real ellipsis. */
.hero-input-group .form-control.user-input:placeholder-shown {
    font-size: clamp(0.72rem, 2.2vw, 0.9rem);
}
.hero-input-group .form-control.user-input:focus {
    background: transparent !important;
    box-shadow: none !important;
}
.hero-input-group .btn {
    border-radius: 50%;
    background: transparent;
    border: none;
}
.input-box {
    border-radius: 1.5rem;
    margin: 0rem 1rem 0.25rem 1rem;
    box-shadow: 0 -4px 8px 0px #0000000d;
}
.input-tip {
    text-align: center;
    font-size: 0.7rem;
    color: #94a3b8;
    padding: 0 1rem;
    line-height: 1.3;
}
html[data-theme='dark'] .input-tip {
    color: #64748b;
}
#chat-card.hero-active .input-tip {
    display: none;
}
.bottom-input-group {
    align-items: flex-end !important;
}
/* Bottom dock mic + send: match the hero dock's clean, borderless icons (the
   default button border draws a circle that, combined with the mic's `left`
   nudge, overlaps the send circle). Cancel that nudge so the icons stay evenly
   spaced. Scoped to these two so the stop button keeps its own styling. */
.bottom-input-group .dictate-btn,
.bottom-input-group .send-btn {
    border: none;
    background: transparent;
}
.bottom-input-group .dictate-btn { left: 0 !important; }
html[data-theme='dark'] .bottom-input-group .form-control.user-input {
    background-color: inherit;
}
/* When hero is active, keep footer hidden and center input */
#chat-card.hero-active .input-box { display: none; }
/* Hide header border on welcome/hero screen */
#chat-card.hero-active .card-header {
    border-bottom-color: transparent !important;
    box-shadow: none;
}

/* Theme toggle visible in embed=false mode */
html.embed-false #theme-toggle-container {
    display: flex !important;
}

.bottom-credit {
    position: absolute;
    bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 8px;
    white-space: pre;
}
.logo-container {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}
.powered-by {
    position: absolute;
    bottom: -16px;
    left: 0;
    white-space: nowrap;
}
.brand-logo { height: 24px; vertical-align: middle; }
.brand-logo-icon { display: none; height: 24px; vertical-align: middle; }
.big-logo { height: 40px; }
html.embed-false .brand-orbit { display: inline; }
.hidden-copy-session-id-btn {
    position: absolute;
    width: 23px;
    height: 100%;
    cursor: pointer;
}
.welcome-text {
    white-space: pre-line;
    span {
        font-weight: bold;
    }
}
/* Custom scrollbar*/
::-webkit-scrollbar {
    width: 6px;
    height: 4px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 3px;
}

.map-container .leaflet-control-attribution {
    font-size: 0.625rem;
    background: rgba(255,255,255,0.72);
}

html[data-theme='dark'] .map-container .leaflet-control-attribution {
    background: rgba(15,23,42,0.72);
    color: #cbd5e1;
}

::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

#new-chat-btn {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.35rem 0.5rem;
    border-radius: 2rem;
    border: 1px solid rgba(2,6,23,0.15);
    color: #334155;
    background: #fff;
    transition: all 160ms ease;
    text-decoration: none !important;
}
#new-chat-btn:hover {
    background: #f8fafc;
    border-color: rgba(2,6,23,0.25);
    color: #0f172a;
    box-shadow: 0 1px 4px rgba(2,6,23,0.08);
}
/* Download shares the header icon color (was falling back to Bootstrap's
   muted .text-secondary, making it lighter than the other header buttons). */
#download-pdf-btn { color: #334155; }
#download-pdf-btn:hover { color: #0f172a; }
/* Hide new session button when on welcome/hero screen */
#chat-card.hero-active #new-chat-btn {
    display: none !important;
}
#chat-card.hero-active #new-chat-btn-2 {
    display: none !important;
}
html[data-theme='dark'] #new-chat-btn {
    border-color: rgba(148,163,184,0.2);
    background: rgba(255,255,255,0.04);
    color: #cbd5e1;
}
html[data-theme='dark'] #new-chat-btn:hover {
    background: rgba(255,255,255,0.08);
    border-color: rgba(148,163,184,0.35);
    color: #e5e7eb;
}
html[data-theme='dark'] #download-pdf-btn { color: #cbd5e1; }
html[data-theme='dark'] #download-pdf-btn:hover { color: #e5e7eb; }
#logout-btn {
    font-weight: 500;
    color: #64748b;
    transition: color 160ms ease, background 160ms ease;
}
#logout-btn:hover {
    color: #334155;
}
html[data-theme='dark'] #logout-btn {
    color: #94a3b8;
}
html[data-theme='dark'] #logout-btn:hover {
    color: #e5e7eb;
}


.blinking-cursor {
    display: inline-block;
    width: 8px;
    height: 1.2rem;
    background-color: #333;
    animation: blink 1s step-end infinite;
}

@keyframes blink {

    from,
    to {
        background-color: transparent;
    }

    50% {
        background-color: #333;
    }
}

.avatar {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
}

.user-avatar {
    background-color: #63c5e5;
    color: #fff;
    margin-bottom: 4px;
}

.bot-message-bubble {
    background-color: #f8fafc;
    border: 1px solid transparent;
    border-radius: 1rem;
    border-top-left-radius: 0.25rem;
    max-width: 85%;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(2,6,23,0.04);
    background-image: linear-gradient(#f8fafc, #f8fafc), linear-gradient(135deg, rgba(0,162,197,0.3), rgba(34,174,86,0.3), rgba(13,110,253,0.3));
    background-origin: border-box;
    background-clip: padding-box, border-box;
}

.user-message-bubble {
    background: linear-gradient(135deg, #00b4d8 0%, #00a2c5 40%, #0090b0 100%);
    color: white;
    border-radius: 1.25rem;
    border-bottom-right-radius: 0.3rem;
    max-width: 85%;
    box-shadow: 0 4px 14px rgba(0,162,197,0.25), 0 1px 3px rgba(0,0,0,0.08);
}

/* Location chip inside user message bubble */
.user-location-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: rgba(255,255,255,0.22);
    border: 1px solid rgba(255,255,255,0.35);
    border-radius: 999px;
    padding: 0.2rem 0.65rem 0.2rem 0.45rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 0.5rem;
    letter-spacing: 0.01em;
}
.user-location-chip-icon {
    font-size: 0.8rem;
    line-height: 1;
}
html[data-theme='dark'] .user-location-chip {
    background: rgba(255,255,255,0.16);
    border-color: rgba(255,255,255,0.28);
}

/* When a chart is present, force the bot bubble to use full available width */
.bot-message-bubble:has(.chart-wrapper) {
    width: 85%;
}

.chart-wrapper {
    min-width: 300px;
    width: 100%;
}

/* Give Plotly a stable box to size into. A min-height keeps the plot area
   readable even when automargin expands the bottom margin to fit long,
   rotated x-axis labels and the axis title. */
.sage-chart {
    width: 100%;
    min-height: 420px;
}

.chart-html-title {
    font-size: 0.95rem;
    font-weight: 600;
    text-align: center;
    padding: 8px 12px 4px;
    line-height: 1.4;
    white-space: normal;
    word-break: break-word;
    color: #495057;
}

html[data-theme='dark'] .chart-html-title {
    color: #e9ecef;
}

.bot-message-bubble>*:last-child,
.user-message-bubble>*:last-child {
    margin-bottom: 0;
}

.bot-message-bubble p,
.user-message-bubble p {
    margin: 0;
}

/* Soften headings inside bot messages */
.bot-message-bubble h1,
.bot-message-bubble h2,
.bot-message-bubble h3,
.bot-message-bubble h4,
.bot-message-bubble h5,
.bot-message-bubble h6 {
    font-weight: 600;
    margin-top: 0.75rem;
    margin-bottom: 0.5rem;
    line-height: 1.3;
}
.bot-message-bubble h1 { font-size: 1.35rem; }
.bot-message-bubble h2 { font-size: 1.2rem; }
.bot-message-bubble h3 { font-size: 1.1rem; }
.bot-message-bubble h4,
.bot-message-bubble h5,
.bot-message-bubble h6 { font-size: 0.95rem; }
.bot-message-bubble h1 strong,
.bot-message-bubble h2 strong,
.bot-message-bubble h3 strong,
.bot-message-bubble h4 strong,
.bot-message-bubble h5 strong,
.bot-message-bubble h6 strong {
    font-weight: 700;
}
.bot-message-bubble strong {
    font-weight: 600;
}

/* Styles for rendered markdown */
.bot-message-bubble ul,
.bot-message-bubble ol {
    padding-left: 1.5rem;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

/* Login brand title toggles */
html.embed-false #login-brand-title .brand-orbit { display: inline; }

.bot-message-bubble ul {
    list-style-type: disc;
}

.bot-message-bubble ol {
    list-style-type: decimal;
}

.bot-message-bubble a {
    color: var(--color-quaternary);
    text-decoration: underline;
}

.bot-message-bubble pre {
    position: relative;
    background-color: #212529;
    color: #f8f9fa;
    padding: 1.5rem 1rem 1rem;
    border-radius: 0.5rem;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
    overflow-x: auto;
}

.bot-message-bubble code {
    color: var(--color-tertiary);
    background-color: #f8f9fa;
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    font-family: monospace;
}

.bot-message-bubble pre code {
    color: inherit;
    background-color: transparent;
    padding: 0;
}

.copy-code-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background-color: #495057;
    color: #f8f9fa;
    border: none;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    cursor: pointer;
    font-size: 0.75rem;
    transition: background-color 0.2s;
}

.copy-code-btn:hover {
    background-color: #6c757d;
}
.bot-message-bubble.aborted {
    font-style: italic;
}
/* Hover-only copy button under each message bubble */
.chat-message { position: relative; }
/* Invisible hover zone that bridges the bubble to the buttons below it,
   so moving the mouse from the bubble onto / between the buttons keeps them visible */
.chat-message::after {
    content: '';
    position: absolute;
    bottom: -20px;
    left: 0;
    right: 0;
    height: 24px;
    pointer-events: auto;
    z-index: 1;
}
.chat-message .message-copy-btn {
    position: absolute;
    z-index: 2; /* Above the hover zone */
    bottom: -16px; /* sit just below bubble */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    padding: 0;
    border: none;
    background: transparent;
    opacity: 0;
    pointer-events: none; /* only active on hover of parent */
    transition: opacity 120ms ease;
}
.chat-message .message-copy-btn img { width: 16px; height: 16px; display: block; }
.chat-message:hover .message-copy-btn { opacity: 1; pointer-events: auto; }
/* Align under respective side */
.chat-message.from-bot .message-copy-btn { left: 58px; }
.chat-message.from-user .message-copy-btn { right: 44px; }

/* Like / dislike feedback buttons — mirror copy button behavior */
.chat-message .message-feedback-btn {
    position: absolute;
    bottom: -16px; /* sit just below bubble */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    padding: 0;
    border: none;
    background: transparent;
    opacity: 0;
    pointer-events: none; /* only active on hover of parent */
    transition: opacity 120ms ease, transform 120ms ease, color 200ms ease;
    border-radius: 50%;
    z-index: 2;
}
.chat-message .message-feedback-btn img {
    width: 16px;
    height: 16px;
    display: block;
    transition: transform 150ms ease;
}
.chat-message:hover .message-feedback-btn { opacity: 1; pointer-events: auto; }
/* Position like/dislike to the right of the copy button (copy at 58px) */
.chat-message.from-bot .message-feedback-btn.like-btn { left: 84px; }
.chat-message.from-bot .message-feedback-btn.dislike-btn { left: 110px; }
/* Hover / active / submitted effects */
.message-feedback-btn:hover { transform: translateY(-1px) scale(1.2); }
.message-feedback-btn:hover img { transform: scale(1.2); }
.message-feedback-btn.feedback-submitted img { transform: scale(1.1); }
.message-feedback-btn:active { transform: translateY(0) scale(0.95); }
@keyframes feedbackPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Ensure bubbles have extra bottom spacing to avoid overlap */
.bot-message-bubble, .user-message-bubble { margin-bottom: 6px; }
.chat-message {
    margin-bottom: 0.75rem;
}
.user-input {
    /* background-color: #e9ecef; */
    box-shadow: none;
    border-radius: 2rem !important;
    resize: none;
    overflow-y: auto;
    scrollbar-gutter: stable both-edges;
    background-clip: padding-box;
    min-height: 40px !important;
}
.user-input-bottom {
    padding-top: 0.5rem !important;
    /* Transparent while empty so the frosted glass shows through; a solid
       backing appears only once text is entered, keeping typing readable. */
    background-color: transparent !important;
    border-radius: 0.9rem;
    transition: background-color 160ms ease;
}
.user-input-bottom:not(:placeholder-shown) {
    background-color: #ffffff !important;
}
html[data-theme='dark'] .user-input-bottom:not(:placeholder-shown) {
    background-color: #1e293b !important;
}
.send-btn {
    border-radius: 50% !important;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 160ms ease, transform 120ms ease;
}
.send-btn:hover {
    background: rgba(0,162,197,0.1);
    transform: scale(1.05);
}
.stop-btn {
    border-radius: 50% !important;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: #f1f5f9;
    border: 1px solid rgba(2,6,23,0.1);
    transition: background 160ms ease, transform 120ms ease;
    margin-left: 2px !important;
}
.stop-btn img {
    width: 18px;
    height: 18px;
}
.stop-btn:hover {
    background: #e2e8f0;
    transform: scale(1.05);
}
.stop-btn:hover img {
    opacity: 1;
}
html[data-theme='dark'] .stop-btn {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.12);
    filter: none;
}
html[data-theme='dark'] .stop-btn img {
    filter: invert(1);
}
html[data-theme='dark'] .stop-btn:hover {
    background: rgba(255,255,255,0.14);
}
.form-control:focus {
    box-shadow: 0 0 0 1px rgba(13, 110, 253, .25) !important;
}
.user-input-bottom.form-control:focus {
    box-shadow: none !important;
}

/* Dictation (speech input) */
.dictate-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--color-primary);
    border: 1px solid transparent;
    border-radius: 3rem !important;
    transition: background-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
    position: relative;
    left: 0.5rem !important;
}
.dictate-btn:hover { background: rgba(0,162,197,0.08); }
.dictate-btn.recording { color: #dc3545; }
html[data-theme='dark'] .dictate-btn { color: var(--color-primary); }
html[data-theme='dark'] .dictate-btn:hover { background: rgba(255,255,255,0.08); }
html[data-theme='dark'] .dictate-btn.recording { color: #f87171; }

.dictation-overlay-inline {
    position: absolute;
    right: 0;
    bottom: 100%;
    transform: translateY(-0.5rem);
    background: var(--color-card, #fff);
    border: 1px solid var(--color-border, rgba(0,0,0,0.1));
    padding: .5rem .75rem;
    border-radius: .75rem;
    box-shadow: var(--shadow-md, 0 8px 24px rgba(0,0,0,0.15));
    display: flex;
    flex-direction: column;
    gap: .5rem;
    width: 260px;
    z-index: 2000;
    animation: scaleIn 160ms ease;
}
html[data-theme='dark'] .dictation-overlay-inline { background: #0f172a; }
.dictation-waveform {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 28px;
}
.dictation-waveform .bar {
    flex: 1 0 0;
    background: linear-gradient(180deg, var(--color-primary), var(--color-quaternary));
    width: 4px;
    border-radius: 2px;
    animation: wf 600ms ease-in-out infinite;
    transform-origin: bottom;
}
.dictation-waveform .bar:nth-child(2) { animation-delay: 120ms; }
.dictation-waveform .bar:nth-child(3) { animation-delay: 240ms; }
.dictation-waveform .bar:nth-child(4) { animation-delay: 360ms; }
.dictation-waveform .bar:nth-child(5) { animation-delay: 480ms; }
@keyframes wf { 0%,100% { height: 4px; } 50% { height: 100%; } }
.dictation-actions { display: flex; justify-content: flex-end; gap: .5rem; }
.dictation-actions button {
    border: 1px solid var(--color-border, rgba(0,0,0,0.1));
    background: transparent;
    padding: .25rem .5rem;
    border-radius: .5rem;
    font-size: .75rem;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--color-primary);
}
.dictation-actions button.confirm { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.dictation-actions button.confirm:hover { background: #008aa7; }
.dictation-actions button.cancel:hover { background: rgba(0,0,0,0.05); }
html[data-theme='dark'] .dictation-actions button.cancel:hover { background: rgba(255,255,255,0.08); }
html[data-theme='dark'] .dictation-actions button { color: var(--color-quaternary); border-color: var(--color-border); }
html[data-theme='dark'] .dictation-actions button.confirm { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }

/* === Inline Dictation Redesigned (waveform inside input area) === */
.dictation-inline {
    position: absolute;
    right: .5rem;
    bottom: .35rem;
    display: flex;
    align-items: center;
    gap: .8rem;
    z-index: 30;
    pointer-events: none;
}
.hero-input-group.dictating textarea::placeholder {
  line-height: 0; /* reset any browser weirdness for placeholder */
}

.dictation-inline .dictation-bars, .dictation-inline .dictation-dots { display:flex; align-items:flex-end; gap:3px; height:28px; width:120px; pointer-events:none; }
.dictation-inline .dictation-bars .bar { width:6px; background:linear-gradient(180deg, var(--color-primary), var(--color-quaternary)); border-radius:3px; height:6px; transition:height 90ms ease; }
html[data-theme='dark'] .dictation-inline .dictation-bars .bar { background:linear-gradient(180deg, var(--color-quaternary), var(--color-primary)); }
.dictation-inline .dictation-dots span { width:6px; height:6px; background:var(--color-primary); border-radius:50%; opacity:.35; animation:dots-blink 1.2s ease-in-out infinite; }
.dictation-inline .dictation-dots span:nth-child(2){ animation-delay:.2s; }
.dictation-inline .dictation-dots span:nth-child(3){ animation-delay:.4s; }
@keyframes dots-blink { 0%,100%{opacity:.2; transform:translateY(0);} 50%{opacity:.9; transform:translateY(-4px);} }
.dictation-inline .dictation-ctrls { display:flex; gap:.4rem; pointer-events:auto; }
.dictation-inline .dictation-ctrls button { width:32px; height:32px; border-radius:50%; border:1px solid var(--color-border, rgba(0,0,0,0.15)); display:inline-flex; align-items:center; justify-content:center; background:var(--color-card,#fff); color:var(--color-primary); cursor:pointer; font-size:16px; line-height:1; transition:background-color 140ms ease, color 140ms ease, box-shadow 140ms ease; }
html[data-theme='dark'] .dictation-inline .dictation-ctrls button { background:#0f172a; color:var(--color-quaternary); }
.dictation-inline .dictation-ctrls button:hover { background:var(--color-primary); color:#fff; }
html[data-theme='dark'] .dictation-inline .dictation-ctrls button:hover { background:var(--color-primary); color:#fff; }
.dictation-inline .dictation-ctrls button.confirm { background:var(--color-primary); color:#fff; }
.dictation-inline .dictation-ctrls button.confirm:hover { filter:brightness(.92); }
.dictation-inline .dictation-ctrls button.cancel:hover { background:#dc3545; color:#fff; }
html[data-theme='dark'] .dictation-inline .dictation-ctrls button.cancel:hover { background:#ef4444; }
/* .input-group.dictating textarea.user-input { padding-right:170px; }
@media (max-width:640px){ .input-group.dictating textarea.user-input { padding-right:140px; } } */

/* Hide mic & send buttons during active dictation */
.input-group.dictating #mic-btn,
.input-group.dictating #send-btn,
.input-group.dictating #hero-mic-btn,
.input-group.dictating #hero-send-btn { opacity:0; visibility:hidden; pointer-events:none; transition:opacity 120ms ease; }
.input-group:not(.dictating) #mic-btn,
.input-group:not(.dictating) #send-btn,
.input-group:not(.dictating) #hero-mic-btn,
.input-group:not(.dictating) #hero-send-btn { opacity:1; visibility:visible; }


.orbitai-icon-border {
    position: relative;
    top: -10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 43px;
    height: 41px;
}
.orbitai-icon-border.emdeded {
    width: 42px;
}
/* The icon SVG now has a large intrinsic size (403x403) for crisp filter
   rasterization, so the message-side icon must be sized explicitly instead of
   relying on the SVG's own dimensions. */
.orbitai-icon-border img {
    width: 23px;
    height: 23px;
}

.orbitai-icon-border-arc {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 1;
    padding: 4px;
    background: conic-gradient(from 135deg,
        var(--color-primary),
        var(--color-secondary),
        var(--color-quaternary),
        var(--color-primary));
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    filter: blur(5px);
    animation: orbitai-pulse-glow 1.2s ease-in-out infinite;
}
@keyframes orbitai-pulse-glow {
    0%, 100% { transform: scale(0.95); opacity: 0.22; }
    50% { transform: scale(1.05); opacity: 0.5; }
}

/* Popup notification for session ID copy */
.popup-notification {
    position: fixed;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-secondary);
    color: #fff;
    padding: 0.5rem 1rem;
    border-radius: 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 9999;
    font-size: 0.8rem;
    opacity: 0;
    transition: opacity 0.5s;
}
.popup-notification.error {
    background: #dc3545;
}

.fullscreen-btn {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    background-color: #f8f9fa;
    color: #495057;
    border: none;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    cursor: pointer;
    font-size: 0.75rem;
    box-shadow:0 2px 8px rgba(0,0,0,0.1);
}
/* Animated rotating gradient border for thinking message (Gemini-style) */
@property --shimmer-angle {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: true;
}
.bot-message-bubble.shimmer-background {
    position: relative;
    overflow: visible;
    animation: borderRotate 1.5s infinite linear;
}
/* Soft blurred comet glow that orbits the bubble (Gemini-style) */
.bot-message-bubble.shimmer-background::before {
    content: "";
    position: absolute;
    inset: -4px;
    z-index: -1;
    border-radius: inherit;
    padding: 4px;
    background: conic-gradient(from var(--shimmer-angle),
        color-mix(in srgb, var(--color-primary) 12%, transparent) 0deg,
        color-mix(in srgb, var(--color-secondary) 12%, transparent) 110deg,
        color-mix(in srgb, var(--color-quaternary) 12%, transparent) 200deg,
        var(--color-primary) 280deg,
        var(--color-secondary) 320deg,
        var(--color-quaternary) 352deg,
        color-mix(in srgb, var(--color-primary) 12%, transparent) 360deg);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    filter: blur(6px);
    opacity: 0.75;
    pointer-events: none;
}
/* Thinking/status text styling */
.shimmer-background .status-text {
    color: #4b5563 !important;
    font-size: 0.85rem;
}

@keyframes borderRotate {
    to {
        --shimmer-angle: 360deg;
    }
}

/* Sessions history overlay - left drawer */
.sessions-overlay {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 88%;
    max-width: 500px;
    background: #fff;
    border-right: 1px solid rgba(2,6,23,0.06);
    box-shadow: 4px 0 20px rgba(2,6,23,0.08);
    transform: translateX(-100%);
    transition: transform 280ms ease;
    z-index: 30;
}
.sessions-overlay.open {
    transform: translateX(0);
}

/* Backdrop behind sessions overlay */
.sessions-backdrop {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(15, 23, 42, 0.25); /* slate-900 @ 45% */
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms ease;
    z-index: 25; /* above header (20), below overlay (30) */
}
.sessions-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}
.sessions-overlay .overlay-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 0.5rem;
}
.sessions-overlay .overlay-header {
    position: sticky;
    top: 0;
    background: rgba(255,255,255,0.98);
    z-index: 1;
    padding: 0.5rem 0.85rem 0.4rem;
}
.sessions-search-toggle,
#close-sessions-overlay,
.sessions-overlay-btn {
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 0.5rem;
    color: #475569;
    border: 1px solid rgba(2,6,23,0.12);
    background: #fff;
    transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}
.sessions-search-toggle svg,
.sessions-overlay-btn svg { width: 16px; height: 16px; }
.sessions-search-toggle:hover, .sessions-search-toggle:focus,
#close-sessions-overlay:hover, #close-sessions-overlay:focus,
.sessions-overlay-btn:hover, .sessions-overlay-btn:focus {
    background: #f1f5f9;
    border-color: rgba(2,6,23,0.2);
    color: #0f172a;
}
html[data-theme='dark'] .sessions-search-toggle,
html[data-theme='dark'] #close-sessions-overlay,
html[data-theme='dark'] .sessions-overlay-btn {
    /* All three header buttons share one look; #close has a later override to
       #cbd5e1 / transparent, so match it here for consistent icon color. */
    color: #cbd5e1;
    border-color: var(--color-border);
    background: transparent;
}
html[data-theme='dark'] .sessions-search-toggle:hover,
html[data-theme='dark'] .sessions-search-toggle:focus,
html[data-theme='dark'] #close-sessions-overlay:hover,
html[data-theme='dark'] #close-sessions-overlay:focus,
html[data-theme='dark'] .sessions-overlay-btn:hover,
html[data-theme='dark'] .sessions-overlay-btn:focus {
    background: rgba(255,255,255,0.08);
    border-color: rgba(148,163,184,0.35);
    color: #e5e7eb;
}
.sessions-search-bar { overflow: hidden; transition: max-height 260ms ease, opacity 200ms ease; max-height:0; opacity:0; }
.sessions-search-bar.open { max-height:120px; opacity:1; }
.sessions-search-bar .search-inner { display:flex; align-items:center; }
.sessions-search-input { padding-right:2rem; background:#f8fafc; }
html[data-theme='dark'] .sessions-search-input { background:#1e293b; color:#f1f5f9; border-color:#334155; }
html[data-theme='dark'] .sessions-search-input:focus { background:#1e293b; color:#fff; }
html[data-theme='dark'] .sessions-search-input::placeholder { color:#64748b; opacity:1; }
/* Empty sessions message styling */
.empty-sessions-msg { color:#475569; }
html[data-theme='dark'] .empty-sessions-msg { color:#cbd5e1; }
.sessions-search-clear { position:absolute; right:.25rem; top:50%; transform:translateY(-50%); color:#64748b; text-decoration:none; font-size:1.1rem; padding:.125rem .25rem; }
.sessions-search-clear:hover { color:#0f172a; }
/* spinner removed */
html[data-theme='dark'] .sessions-search-clear { color:#94a3b8; }
html[data-theme='dark'] .sessions-search-clear:hover { color:#fff; }
/* spinner removed */
.sessions-overlay .overlay-list {
    overflow-y: auto;
    font-size: small;
    height: calc(100% - 48px);
}
.sessions-overlay .list-loading {
    padding: 0.5rem;
    overflow: unset;
}
.sessions-overlay .list-group-item {
    cursor: pointer;
    border: none;
    border-radius: 0.5rem !important;
    padding: 0.65rem 0.75rem;
    margin: 0.2rem 0.5rem;
    transition: background 150ms ease;
}
.sessions-overlay .list-group-item .session-id {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}
.sessions-overlay .list-group-item.active {
    background-color: rgba(0,162,197,0.08);
    border: none !important;
    color: #0f172a;
    border-left: 3px solid var(--color-primary) !important;
    border-radius: 0 0.5rem 0.5rem 0 !important;
}
.sessions-overlay .list-group-item:not(.active):hover {
    background: rgba(2,6,23,0.03);
}
/* small utility area for actions */
.session-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}
/* Session actions: hover-only kebab and dropdown menu */
.list-group-item .session-actions {
    position: relative;
    display: flex;
    align-items: center;
}

.list-group-item .session-actions .kebab-btn {
    background: transparent;
    border: none;
    line-height: 1;
    font-size: 18px;
    padding: 4px 6px;
    border-radius: 6px;
    color: #6c757d; /* muted */
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 120ms ease, background-color 120ms ease, color 120ms ease;
}

.list-group-item:hover .session-actions .kebab-btn,
.list-group-item .session-actions.open .kebab-btn {
    opacity: 1;
    pointer-events: auto;
}

/* Keep kebab visible for the selected (active) session */
.list-group-item.active .session-actions .kebab-btn {
    opacity: 1;
    pointer-events: auto;
    color: var(--color-primary);
}

.list-group-item.active .session-actions .kebab-btn:hover {
    background: rgba(0,162,197,0.1);
    color: var(--color-primary);
}

.list-group-item .session-actions .kebab-btn:hover {
    background: rgba(0,0,0,0.06);
    color: #343a40;
}

.list-group-item .session-actions .session-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    min-width: 160px;
    background: #fff;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    padding: 6px 0;
    display: none;
    z-index: 5;
}

.list-group-item .session-actions.open .session-menu {
    display: block;
}

.list-group-item .session-actions .session-menu-item {
    width: 100%;
    background: transparent;
    border: none;
    text-align: left;
    padding: 8px 12px;
    font-size: 14px;
    color: #212529;
    cursor: pointer;
}

.list-group-item .session-actions .session-menu-item:hover {
    background: rgba(0,0,0,0.05);
}
.list-group-item .session-actions .session-menu-item.text-danger { color: #dc3545; }
.list-group-item .session-actions .session-menu-item.text-danger:hover { background: rgba(220,53,69,0.08); }
.session-actions .btn-icon {
    border: none;
    background: transparent;
    color: #64748b;
    padding: 0.125rem 0.25rem;
}
.session-actions .btn-icon:hover {
    color: #0f172a;
}

/* Simple spinner */
.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid #cbd5e1;
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* "Preparing PDF…" overlay shown while maps are scrolled into view before print.
   Covers the chat so the scroll-sweep jank is hidden; never printed (see @media print). */
.print-prep-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    background: var(--bs-body-bg, #fff);
    color: #1f2937;
    font-size: 0.95rem;
    font-weight: 500;
}
/* Full-viewport variant for the iOS autoprint window. */
.print-prep-overlay--full {
    position: fixed;
}
.print-prep-overlay .spinner { width: 22px; height: 22px; }
html[data-theme='dark'] .print-prep-overlay {
    background: #0f172a;
    color: #e5e7eb;
}

/* Rename modal */
.rename-modal-overlay {
    position: fixed;
    inset: 0;
    /* Light frosted backdrop so the translucent glass modal reads bright white. */
    background: rgba(255,255,255,0.45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    -webkit-backdrop-filter: blur(10px) saturate(150%);
    backdrop-filter: blur(10px) saturate(150%);
}
.rename-modal-overlay.open {
    display: flex;
}
.rename-modal-dialog {
    background: #fff;
    width: min(92vw, 420px);
    border-radius: 0.5rem;
    padding: 0.75rem 0.75rem 0.75rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    /* Subtle boundary in light mode */
    border: 1px solid var(--color-border);
}

/* Login overlay */
.login-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.65);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}
.login-card {
    position: relative;
    overflow: hidden;
    width: min(92vw, 400px);
    min-height: 380px;
    border-radius: 0.75rem;
    padding: 1.25rem 1.25rem 1rem;
    background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(255,255,255,0.88));
    border: 1px solid rgba(13,110,253,0.08);
    box-shadow: 0 18px 40px rgba(2,6,23,0.18);
    -webkit-backdrop-filter: blur(10px) saturate(1.05);
    backdrop-filter: blur(10px) saturate(1.05);
    display: flex;
    flex-direction: column;
    justify-content: center; /* center content vertically */
    align-items: stretch;
    gap: 1rem; /* consistent spacing between title, error, and form */
}
.login-card::before {
    /* Brand accent bar at the top */
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--color-primary), var(--color-quaternary), var(--color-secondary));
}
.login-card::after {
    /* Soft corner glow */
    content: "";
    position: absolute;
    width: 260px; height: 260px;
    right: -140px; bottom: -140px;
    background: radial-gradient(closest-side, rgba(0,162,197,0.22), transparent 70%);
    filter: blur(10px);
    pointer-events: none;
}
/* Subtle heading tint */
.login-card h5, .login-card .card-title {
    color: var(--color-quaternary);
    font-weight: 600;
}
/* Inputs within the login card */
.login-card .form-control {
    background-color: #f8fafc;
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 0.5rem;
}
.login-card .form-control:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 .2rem rgba(0, 162, 197, .2) !important;
}
/* Primary action button inside login card */
.login-card #login-submit, .login-card .btn-primary {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
    box-shadow: 0 6px 16px rgba(0, 162, 197, 0.25);
}
.login-card #login-submit:hover, .login-card .btn-primary:hover {
    background-color: #008aa7;
    border-color: #008aa7;
}
.login-card #login-submit:focus-visible, .login-card .btn-primary:focus-visible {
    box-shadow: 0 0 0 .2rem rgba(0, 162, 197, .35) !important;
}
/* Error text */
#login-error { color: var(--color-tertiary); font-weight: 500; min-height: 1.125rem; }
/* Ensure error appears above the login button */
.login-card .d-flex.justify-content-between.align-items-center {
    display: grid !important;
    grid-template-columns: 1fr;
    align-items: start;
    gap: 0.5rem;
}
/* Layout and spacing inside login card */
.login-card h5, .login-card .card-title { margin-bottom: 0.5rem; }
.login-card form {
    display: grid;
    grid-template-columns: 1fr;
    align-items: start;
    gap: 0.75rem;
}
@media (min-width: 480px) {
    .login-card form { gap: 1rem; }
}
.login-card label { margin-bottom: 0.25rem; color: #334155; font-weight: 500; }
.login-card .form-group,
.login-card .input-group,
.login-card .form-floating,
.login-card .mb-3 { margin-bottom: 0 !important; }
.login-card .form-control { width: 100%; }
.login-card .btn { width: 100%; min-height: 44px; border-radius: 0.5rem; }
.login-card .btn-row { display: flex; align-items: center; gap: 0.5rem; }
.login-card .btn-row .btn { flex: 1 0 0; }
.login-card #login-error { margin-top: 0.25rem; }
/* Custom button styles */
.custom-primary-btn {
    background-color: var(--color-primary);
    color: #fff;
    border: 1px solid var(--color-primary);
    border-radius: 0.375rem;
}
.custom-primary-btn:hover {
    background-color: #0094b6;
    border-color: #0094b6;
    color: #fff;
}
.custom-primary-btn:focus {
    outline: none;
    box-shadow: 0 0 0 .125rem rgba(0, 162, 197, .25);
}
.custom-primary-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}
/* Secondary / outline button (e.g. "Create Account" on the login gate) */
.custom-secondary-btn {
    background-color: transparent;
    color: var(--color-primary);
    border: 1px solid var(--color-primary);
    border-radius: 0.375rem;
}
.custom-secondary-btn:hover {
    background-color: rgba(0, 162, 197, 0.08);
    border-color: #0094b6;
    color: #0094b6;
}
.custom-secondary-btn:focus {
    outline: none;
    box-shadow: 0 0 0 .125rem rgba(0, 162, 197, .25);
}
/* Google sign-in button + "or" divider on the login gate */
.login-card .google-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    background-color: #fff;
    color: #1f1f1f;
    border: 1px solid #d0d5dd;
    border-radius: 0.375rem;
    font-weight: 500;
}
.login-card .google-btn:hover {
    background-color: #f8fafc;
    border-color: #b6bec9;
    color: #1f1f1f;
}
.login-card .google-btn:focus {
    outline: none;
    box-shadow: 0 0 0 .125rem rgba(0, 162, 197, .25);
}
.login-card .google-btn svg { flex: 0 0 auto; }
.login-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #94a3b8;
    font-size: 0.8rem;
    margin: 0.25rem 0;
}
.login-divider::before,
.login-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: rgba(100,116,139,0.25);
}
/* Login gate subtitle */
.login-subtitle {
    color: var(--color-text-muted, #64748b);
    font-size: 0.9rem;
}
/* Hero brand title */
#hero-brand-title {
    font-size: 40px; /* larger */
    font-weight: 600;
    background-image: linear-gradient(to right, #69d9f0 0%, #6be6b3 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    display: inline-block;
}

/* Hero content alignment */
.hero-overlay .hero-content {
    transform: none;
    height: auto;
}

/* Login brand title (smaller to fit card) */
#login-brand-title {
    font-size: 28px;
    font-weight: 600;
    line-height: 1.1;
    background-image: linear-gradient(to right, #69d9f0 0%, #6be6b3 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* Keep Orbit word in gradient, color AI #00a2c5 in hero/login when non-embed */
html.embed-false #hero-brand-title .brand-orbit .orbit-word,
html.embed-false #login-brand-title .brand-orbit .orbit-word {
    background-image: linear-gradient(to right, #69d9f0 0%, #6be6b3 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
html.embed-false #hero-brand-title .brand-orbit .orbit-ai,
html.embed-false #login-brand-title .brand-orbit .orbit-ai {
    color: #0d9dfd;
    -webkit-background-clip: initial;
    background-clip: initial;
    font-weight: lighter;
}


/* Delete modal (mirrors rename modal) */
.delete-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.4);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    -webkit-backdrop-filter: blur(4px) saturate(120%);
    backdrop-filter: blur(4px) saturate(120%);
}
.delete-modal-overlay.open { display: flex; }
.delete-modal-dialog {
    /* Subtle boundary in light mode */
    border: 1px solid var(--color-border);
    background: #fff;
    width: min(92vw, 420px);
    border-radius: 0.5rem;
    padding: 0.75rem 0.75rem 0.75rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}

/* ==========================
     UI Makeover: Chat Enhancements
     ========================== */
.bot-message-bubble:hover {
    transform: none !important;
    box-shadow: var(--shadow-sm);
}
.user-message-bubble:hover {
    transform: none !important;
    box-shadow: 0 6px 20px rgba(0,162,197,0.3), 0 2px 6px rgba(0,0,0,0.1);
}

/* 2) Sessions list spacing between items */
.sessions-overlay .overlay-list .list-group-item {
    margin: 2px 0;
}

/* 3) Ensure session action menu renders above neighbors */
.list-group-item .session-actions .session-menu {
    z-index: 1002; /* above list items and sticky header */
}
/* Elevate stacking when the actions menu is open */
.list-group-item .session-actions.open {
    position: relative;
    z-index: 1003;
}

/* 3b) Prevent hovered items from creating a higher stacking context than open menus */
.sessions-overlay .list-group-item {
    position: relative; /* enable z-index stacking */
}
/* Remove transform on hover to avoid new stacking contexts overshadowing menus */
.sessions-overlay .list-group-item:not(.active):hover {
    transform: none !important;
}

/* 4) Add breathing room between overlay header and list */
.sessions-overlay .overlay-header {
    padding-bottom: 0.6rem;
    border-bottom: 1px solid rgba(2,6,23,0.06);
}
.sessions-overlay .overlay-list {
    margin-top: 0.25rem;
}

/* === Design System Variables === */
:root {
    --color-primary: #00a2c5;
    --color-primary-rgb: 0,162,197;
    /* --color-primary-new: #69d9f0; */
    --color-secondary: #22ae56;
    /* --color-secondary-new: #6be6b3; */
    --color-tertiary: #d63384;
    --color-quaternary: #0d6efd;
    /* --color-quaternary-new: #4b98ee; */

    --color-bg: #f8f9fa;
    --color-card: #ffffff;
    --color-muted: #64748b;
    --color-border: rgba(2, 6, 23, 0.08);
    --shadow-sm: 0 4px 10px rgba(2, 6, 23, 0.06);
    --shadow-md: 0 10px 25px rgba(2, 6, 23, 0.12);
    --shadow-lg: 0 18px 40px rgba(2, 6, 23, 0.18);
    --radius-sm: .375rem;
    --radius-md: .75rem;
    --radius-lg: 1.25rem;
    --radius-pill: 999px;
}

/* Global background with subtle radial washes */
body {
    background:
        radial-gradient(1200px 800px at 10% -10%, rgba(13,110,253,0.06), transparent 60%),
        radial-gradient(1000px 600px at 110% 10%, rgba(0,162,197,0.08), transparent 60%),
        var(--color-bg);
    color: #0f172a;
}

/* Chat card: soft glassy panel */
#chat-card {
    background: linear-gradient(180deg, rgba(255,255,255,0.86), rgba(255,255,255,0.94));
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-md);
    contain: layout style paint;
}

/* Hero overlay: gentle entrance handled by opacity transition */

/* Input dock: floating, airy */
/* Liquid glass dock: frosted, translucent bar floating over the conversation.
   Subtle 10px blur so scrolled messages read softly through the material. */
.input-box {
    position: relative;
    overflow: visible;
    -webkit-backdrop-filter: blur(10px) saturate(180%);
    backdrop-filter: blur(10px) saturate(180%);
    /* Faint cool tint (not pure white) + a defining hairline and lift-off
       shadow so the pane reads as floating glass even over a white chat. */
    background: linear-gradient(180deg, rgba(255,255,255,0.5) 0%, rgba(236,244,248,0.36) 100%);
    border: 1px solid rgba(148,163,184,0.3);
    box-shadow:
        0 10px 30px -8px rgba(2,6,23,0.28),
        inset 0 1px 0 0 rgba(255,255,255,0.9);
    transition: box-shadow 200ms ease, border-color 200ms ease, background 200ms ease;
}
/* Focus = a soft teal light blooms from inside the lower edge (no border). */
.input-box:focus-within {
    box-shadow:
        0 12px 32px -8px rgba(2,6,23,0.30),
        inset 0 1px 0 0 rgba(255,255,255,0.95),
        inset 0 -14px 22px -14px rgba(0,162,197,0.5);
}

/* Inputs: crisp borders + responsive focus ring */
.form-control.user-input {
    border: 1px solid rgba(2,6,23,0.06);
    transition: box-shadow 160ms ease, border-color 160ms ease, height 160ms ease, background-color 160ms ease;
}
.hero-input-group .form-control.user-input { background: transparent; border: none; }
.hero-input-group .form-control.user-input:focus { background: transparent !important; box-shadow: none !important; border: none !important; }
.form-control:focus {
    box-shadow: 0 0 0 .16rem rgba(13, 110, 253, .20) !important;
    border-color: rgba(13,110,253,.35) !important;
}

/* Fancy brand gradients with a slow shimmer */
#hero-brand-title,
#login-brand-title {
    background-size: 200% auto;
    animation: gradientShift 8s ease infinite;
}

/* Message bubbles: depth + micro-interactions */
/* .bot-message-bubble,
.user-message-bubble { transition: transform 180ms ease, box-shadow 180ms ease, background-color 180ms ease; }
.bot-message-bubble { box-shadow: 0 2px 8px rgba(2,6,23,0.06); }
.user-message-bubble { box-shadow: 0 2px 10px rgba(0,162,197,0.22); }
.bot-message-bubble:hover,
.user-message-bubble:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); } */

/* Chat message mount animations */
.chat-message.from-user {
    animation: slideUpFadeIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    animation-fill-mode: both;
}
.chat-message.from-user .user-message-bubble {
    transform: translateY(0);
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
.chat-message.from-bot {
    animation: slideDownFadeIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    animation-fill-mode: both;
}
.chat-message.from-bot .bot-message-bubble {
    transform: translateY(0);
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Hover controls polish */
.copy-code-btn { transition: background-color 0.2s, transform 120ms ease; }
.copy-code-btn:hover { transform: translateY(-1px); }
.chat-message .message-copy-btn { transition: opacity 120ms ease, transform 120ms ease; }
.chat-message .message-copy-btn:hover { transform: translateY(-1px) scale(1.02); }

/* Scrollbar: subtle gradient */
::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #cbd5e1, #94a3b8);
}

/* Map/image controls */
.fullscreen-btn { transition: transform 140ms ease, box-shadow 180ms ease, background-color 180ms ease; }
.fullscreen-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.fullscreen-btn:active { transform: translateY(0); }

/* Session drawer: smoother slide and glass effect */
.sessions-overlay {
    transition: transform 320ms cubic-bezier(.2,.8,.2,1);
    box-shadow: 2px 0 18px rgba(0,0,0,0.08);
    backdrop-filter: blur(8px) saturate(1.02);
}
.sessions-overlay .list-group-item:not(.active):hover {
    transform: none;
}
.list-group-item .session-actions .kebab-btn { transition: opacity 120ms ease, background-color 120ms ease, color 120ms ease, transform 120ms ease; }
.list-group-item .session-actions .kebab-btn:active { transform: scale(0.98); }
.list-group-item .session-actions .session-menu { animation: scaleIn 160ms ease both; }

/* Active session request indicators */
.session-status { display:inline-flex; align-items:center; margin-left:6px; flex-shrink:0; }
/* Base dot — primary theme color, compact */
.session-active-dot { position:relative; display:inline-block; width:8px; height:8px; border-radius:50%; background: #00a2c5; }
/* Fetching phase: animated pulse */
.session-active-dot.fetching { background: #00a2c5; animation: pulseDotBg 1.2s ease-in-out infinite; }
/* Typing/rendering phase */
.session-active-dot.typing { background: #00a2c5; }
/* Done/unseen: subtle secondary */
.session-active-dot.done { background: #22ae56; }
/* Animated outer ring only for fetching */
.session-active-dot.fetching::after { content:""; position:absolute; inset:-4px; border-radius:50%; border:2px solid #00a2c5; animation: pulseDot 1.2s ease-in-out infinite; }
@keyframes pulseDot { 0% { transform:scale(.7); opacity:.7;} 50% { transform:scale(1.15); opacity:.1;} 100% { transform:scale(.7); opacity:.7;} }
@keyframes pulseDotBg { 0%,100% { opacity:1;} 50% { opacity:.5;} }
/* Dark mode */
[data-bs-theme="dark"] .session-active-dot { background: #00a2c5; }
[data-bs-theme="dark"] .session-active-dot.done { background: #22ae56; }

/* Session Title Dropdown */
.session-title-container {
    flex: 1;
    display: flex;
    justify-content: center;
    margin: 0 0.25rem;
    max-width: 45vw;
}
.session-title-dropdown-wrapper {
    position: relative;
    max-width: 100%;
}
.session-title-btn {
    border-radius: 0.5rem;
    padding: 0.35rem 0.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    color: #334155;
    font-size: 0.813rem;
    font-weight: 500;
    height: 32px;
    transition: all 0.2s ease;
    white-space: nowrap;
    border: 1px solid transparent;
    background: transparent;
}
.session-title-btn:hover {
    background: #f8fafc;
    border-color: rgba(0, 162, 197, 0.2);
    color: #1e293b;
}
.session-title-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 162, 197, 0.1);
    border-color: var(--color-primary);
}
.session-title-btn.active {
    border-color: var(--color-primary);
    background: rgba(0, 162, 197, 0.05);
}
.session-title-text {
    flex: 1;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 0.25rem;
    min-width: 0;
    line-height: 1.3;
}
.session-dropdown-arrow {
    flex-shrink: 0;
    transition: transform 0.2s ease;
    color: #64748b;
}
.session-title-btn.active .session-dropdown-arrow {
    transform: rotate(180deg);
}
.session-options-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 50%;
    transform: translateX(-50%) translateY(-8px) scale(0.95);
    background: #fff;
    border: 1px solid rgba(2,6,23,0.08);
    border-radius: 0.5rem;
    box-shadow: 0 10px 30px rgba(2,6,23,0.15);
    min-width: 130px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1050;
}
.session-options-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0) scale(1);
}
.session-options-dropdown .dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    color: #334155;
    font-size: 0.813rem;
    cursor: pointer;
    transition: all 0.15s ease;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    border-radius: 0.5rem;
}
.session-options-dropdown .dropdown-item:hover {
    background: #f1f5f9;
    color: #1e293b;
}
.session-options-dropdown .dropdown-item svg {
    flex-shrink: 0;
    color: #64748b;
}
.session-options-dropdown .dropdown-item:hover svg {
    color: #334155;
}
#session-delete-option {
    color: #dc3545;
}
#session-delete-option svg {
    color: #dc3545;
}
#session-delete-option:hover {
    background: rgba(220,53,69,0.08);
    color: #dc3545;
}
#session-delete-option:hover svg {
    color: #dc3545;
}
/* Dark mode Session Title */
html[data-theme='dark'] .session-title-btn {
    color: #cbd5e1;
    background: transparent;
}
html[data-theme='dark'] .session-title-btn:hover {
    background: rgba(15,23,42,0.8);
    border-color: rgba(0, 162, 197, 0.3);
    color: #e5e7eb;
}
html[data-theme='dark'] .session-title-btn:focus {
    box-shadow: 0 0 0 3px rgba(0, 162, 197, 0.15);
    border-color: var(--color-primary);
}
html[data-theme='dark'] .session-title-btn.active {
    border-color: var(--color-primary);
    background: rgba(0, 162, 197, 0.1);
}
html[data-theme='dark'] .session-dropdown-arrow {
    color: #94a3b8;
}
html[data-theme='dark'] .session-options-dropdown {
    background: #1e293b;
    border-color: rgba(148,163,184,0.15);
    box-shadow: 0 10px 30px rgba(2,6,23,0.7);
}
html[data-theme='dark'] .session-options-dropdown .dropdown-item {
    color: #cbd5e1;
}
html[data-theme='dark'] .session-options-dropdown .dropdown-item:hover {
    background: rgba(30,41,59,0.6);
    color: #e5e7eb;
}
html[data-theme='dark'] .session-options-dropdown .dropdown-item svg {
    color: #94a3b8;
}
html[data-theme='dark'] .session-options-dropdown .dropdown-item:hover svg {
    color: #cbd5e1;
}
html[data-theme='dark'] #session-delete-option {
    color: #f87171;
}
html[data-theme='dark'] #session-delete-option svg {
    color: #f87171;
}
html[data-theme='dark'] #session-delete-option:hover {
    background: rgba(248,113,113,0.08);
    color: #f87171;
}
html[data-theme='dark'] #session-delete-option:hover svg {
    color: #f87171;
}

/* Interaction Blocking Overlay */
.interaction-blocking-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Frost the whole screen while blocking, so the loading card reads as glass
       over the blurred app instead of a white card on a flat white scrim. */
    background: rgba(255, 255, 255, 0.4);
    -webkit-backdrop-filter: blur(10px) saturate(150%);
    backdrop-filter: blur(10px) saturate(150%);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
.interaction-blocking-overlay.active {
    display: flex;
}
.interaction-blocking-overlay .loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 24px 32px;
    background: var(--color-card, #fff);
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
}
.interaction-blocking-overlay .loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(0, 162, 197, 0.2);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.interaction-blocking-overlay .loading-text {
    font-size: 0.875rem;
    color: #64748b;
    font-weight: 500;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
html[data-theme='dark'] .interaction-blocking-overlay {
    background: rgba(15, 23, 42, 0.4);
}
html[data-theme='dark'] .interaction-blocking-overlay .loading-content {
    background: #1e293b;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}
html[data-theme='dark'] .interaction-blocking-overlay .loading-text {
    color: #94a3b8;
}
html[data-theme='dark'] .interaction-blocking-overlay .loading-spinner {
    border-color: rgba(0, 162, 197, 0.15);
    border-top-color: var(--color-primary);
}

/* Modals and cards: scale-in */
.rename-modal-dialog,
.delete-modal-dialog,
.login-card { animation: scaleIn 200ms ease both; }

/* Success/error toasts */
.popup-notification {
    top: 12px;
    background: linear-gradient(90deg, var(--color-secondary), #16c172);
    box-shadow: var(--shadow-md);
    transition: opacity 300ms ease, transform 300ms ease;
    transform-origin: top center;
}
.popup-notification.error { background: linear-gradient(90deg, #dc3545, #ef476f); }

/* Keyframes */
@keyframes slideUpFadeIn {
    0% { opacity: 0; transform: translateY(50px) translateX(50px) scale(0.75); }
    100% { opacity: 1; transform: translateY(0) translateX(0) scale(1); }
}
@keyframes slideDownFadeIn {
    0% { opacity: 0; transform: translateY(-50px) translateX(-50px) scale(0.75); }
    100% { opacity: 1; transform: translateY(0) translateX(0) scale(1); }
}
@keyframes scaleIn { from { opacity: 0; transform: scale(0.98);} to { opacity: 1; transform: scale(1);} }
@keyframes fadeSlideIn { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: translateY(0);} }
@keyframes gradientShift { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }

/* Accessibility: respect reduced motion */
@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}

/* ==========================
     Dark Mode Toggle + Theme
     ========================== */
.theme-toggle-btn {
    color: #334155;
    border-radius: 999px;
    border: 1px solid rgba(2,6,23,0.08);
    background: #fff;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    box-shadow: 0 2px 8px rgba(2,6,23,0.08);
}
.theme-toggle-btn:hover { background: #f8fafc; }
.theme-toggle-btn .icon-sun { display: none; }
.theme-toggle-btn.is-dark .icon-moon { display: none; }
.theme-toggle-btn.is-dark .icon-sun { display: inline-flex; }

/* Light (default) variables already set above; Dark overrides below */
html[data-theme='dark'] {
    --color-bg: #0b1220;
    --color-card: #0f172a;
    --color-muted: #9aa4b2;
    --color-border: rgba(148,163,184,0.18);
    color-scheme: dark;
}

/* Theme reveal animation (directional, performant) */
:root { view-transition-name: root; }
@media (prefers-reduced-motion: no-preference) {
    /* Simple, smooth circular reveal only */
    html.theme-animating::view-transition-old(root) { animation: none; }
        html.theme-animating::view-transition-new(root) {
        will-change: clip-path;
        contain: paint;
            animation: theme-reveal 360ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
        clip-path: circle(0 at var(--vt-x, 100%) var(--vt-y, 0%));
    }
    @keyframes theme-reveal {
        to { clip-path: circle(var(--vt-r, 150vmax) at var(--vt-x, 100%) var(--vt-y, 0%)); }
    }
}

/* Page background */
html[data-theme='dark'] body {
    background:
        radial-gradient(1200px 800px at 10% -10%, rgba(13,110,253,0.12), transparent 60%),
        radial-gradient(1000px 600px at 110% 10%, rgba(0,162,197,0.14), transparent 60%),
        var(--color-bg);
    color: #e5e7eb;
}

/* Chat card */
html[data-theme='dark'] #chat-card {
    background: linear-gradient(180deg, rgba(15,23,42,0.78), rgba(15,23,42,0.86));
    border-color: var(--color-border);
    box-shadow: 0 10px 30px rgba(2,6,23,0.5);
}

/* Header tweaks */
.card-header {
    background: linear-gradient(180deg, rgba(255,255,255,0.72), rgba(255,255,255,0.55));
    border-bottom: 1px solid rgba(2,6,23,0.06) !important;
    padding: 0.5rem 0.75rem 0.85rem !important;
    -webkit-backdrop-filter: blur(18px) saturate(180%);
    backdrop-filter: blur(18px) saturate(180%);
    box-shadow:
        0 1px 4px rgba(2,6,23,0.06),
        inset 0 1px 0 0 rgba(255,255,255,0.85);
    overflow: visible;
    /* Float over the chat so messages blur through it as they scroll under. */
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 20;
}
.card-header .d-flex {
    gap: 0.6rem;
}
.new-session-btn {
    display: flex;
    align-items: center;
    gap: 0.125rem;
    font-size: 0.875rem;
    padding: 0.2rem;
    border-radius: 0.4rem;
    /* border/box-shadow left to the shared header-chip rule so this button
       matches the others (previously forced off with !important). */
    border: none;
    box-shadow: none;
    outline: none;
    background: transparent;
}
#new-chat-btn {
    margin-left: 0;
}

/* Settings Toggle Button */
.settings-toggle-btn {
    color: #334155;
    border-radius: 999px;
    border: 1px solid rgba(2,6,23,0.08);
    background: #fff;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(2,6,23,0.08);
    transition: all 0.2s ease;
    margin-right: 0.5rem;
}
.settings-toggle-btn:hover {
    background: #f8fafc;
    transform: rotate(90deg);
}
.settings-toggle-btn:active {
    transform: rotate(180deg) scale(0.95);
}
.settings-toggle-btn.active {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
    transform: rotate(90deg);
}

/* Settings Container */
.settings-container {
    position: relative;
}

/* Settings Dropdown */
.settings-dropdown {
    position: absolute;
    top: calc(100% + 0.25rem);
    right: -100%;
    background: #fff;
    border: 1px solid rgba(2,6,23,0.08);
    border-radius: 0.75rem;
    box-shadow: 0 10px 30px rgba(2,6,23,0.15);
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.95);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    backdrop-filter: blur(8px);
}
.settings-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Settings Content */
.settings-content {
    padding: 0.75rem;
}
.settings-header {
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(2,6,23,0.08);
    margin-bottom: 0.75rem;
}
.settings-header h6 {
    color: #1e293b;
    font-weight: 600;
    font-size: 0.875rem;
    margin: 0;
}
.settings-body {
    min-height: 40px;
}

/* Setting Item */
.setting-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.5rem;
    width: 100%;
    font-size: 0.875rem;
    border-radius: 0.5rem;
    cursor: pointer;
    /* Override Bootstrap's muted .text-secondary (which is !important) for a
       readable label on the frosted panel. Dark mode below also uses
       !important so it still wins there. */
    color: #334155 !important;
}
.setting-item:hover {
    background: rgba(2,6,23,0.04);
}
html[data-theme='dark'] .setting-item:hover {
    background: rgba(255,255,255,0.05);
}
.setting-item svg,
.setting-item img {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

#history-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.3rem;
    margin-right: 0.5rem;
    border-radius: 0.4rem;
    border: none;
    background: transparent;
    color: #64748b;
    transition: background 150ms ease, color 150ms ease;
}
#history-btn:hover {
    background: rgba(2,6,23,0.05);
    color: #334155;
}
#history-btn img {
    width: 28px;
    height: 28px;
}
html[data-theme='dark'] #history-btn {
    color: #94a3b8;
    background: transparent;
}
html[data-theme='dark'] #history-btn:hover {
    background: rgba(255,255,255,0.06);
    color: #e5e7eb;
}
html[data-theme='dark'] .card-header { border-color: var(--color-border) !important; background: linear-gradient(180deg, rgba(30,41,59,0.55), rgba(15,23,42,0.45)); box-shadow: 0 1px 4px rgba(0,0,0,0.3), inset 0 1px 0 0 rgba(255,255,255,0.12); }
html[data-theme='dark'] .powered-by { color: var(--color-muted) !important; }
html[data-theme='dark'] .theme-toggle-btn { background: #0b1220; color: #cbd5e1; border-color: var(--color-border); box-shadow: 0 2px 10px rgba(2,6,23,0.6); }
html[data-theme='dark'] .theme-toggle-btn:hover { background: #0f172a; }
/* Dark mode Settings */
html[data-theme='dark'] .settings-toggle-btn {
    background: #0b1220;
    color: #cbd5e1;
    border-color: var(--color-border);
    box-shadow: 0 2px 10px rgba(2,6,23,0.6);
}
html[data-theme='dark'] .settings-toggle-btn:hover {
    background: #0f172a;
    transform: rotate(90deg);
}
html[data-theme='dark'] .settings-toggle-btn:active {
    background: #0f172a;
    transform: rotate(180deg) scale(0.95);
}
html[data-theme='dark'] .settings-toggle-btn.active {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}
html[data-theme='dark'] .settings-dropdown {
    background: linear-gradient(180deg, rgba(15,23,42,0.95), rgba(15,23,42,0.98));
    border-color: var(--color-border);
    box-shadow: 0 10px 30px rgba(2,6,23,0.7);
    backdrop-filter: blur(12px);
}
html[data-theme='dark'] .settings-header {
    border-bottom-color: var(--color-border);
}
html[data-theme='dark'] .settings-header h6 {
    color: #e5e7eb;
}
html[data-theme='dark'] .setting-item {
    color: #cbd5e1 !important;
}
html[data-theme='dark'] .setting-item img {
    filter: invert(1);
}

/* Theme toggle lives inside the Settings menu on mobile only */
.mobile-only-setting { display: none; }

/* New Session / Download PDF live in the session-title dropdown on mobile only */
.session-options-dropdown .title-only-mobile { display: none; }
.session-options-divider {
    height: 1px;
    background: rgba(2,6,23,0.08);
    margin: 0.35rem 0.25rem;
}
html[data-theme='dark'] .session-options-divider { background: rgba(148,163,184,0.15); }

/* ============================================================
   Mobile header (<= 768px). "Powered by Cropin" stays visible.
   Secondary controls move into existing menus:
     - New Session / Download PDF  -> session-title dropdown
     - Theme toggle + Logout       -> Settings gear
   Standalone header icons are hidden. Every rule is scoped to
   this media query, so the desktop header is untouched.
   ============================================================ */
@media screen and (max-width: 768px) {
    /* Reveal the theme item inside the settings dropdown */
    .mobile-only-setting { display: flex; }
    .settings-divider.mobile-only-setting { display: block; }

    /* Reveal the action items inside the session-title dropdown */
    .session-options-dropdown .dropdown-item.title-only-mobile { display: flex; }
    .session-options-dropdown .session-options-divider.title-only-mobile { display: block; }

    /* Hide the standalone header controls now reached via the menus */
    #new-chat-btn,
    #download-pdf-btn { display: none !important; }
    html.embed-false #theme-toggle-container { display: none !important; }

    /* Header fills the row; protect the logo/history, let only the title shrink */
    .left-top-header-container { flex: 1 1 auto; min-width: 0; }
    .center-top-header-container { flex: 1 1 auto; min-width: 0; }
    #history-btn,
    .logo-container { flex: 0 0 auto; }
    .session-title-container {
        flex: 0 1 auto;          /* sized to content, never grows past the cap */
        max-width: 60vw;         /* wider now that new-chat/download/theme moved into the menu */
        min-width: 0;            /* but may shrink + ellipsize when space is tight */
        margin: 0 0.25rem;
    }
    .session-title-dropdown-wrapper,
    .session-title-btn { min-width: 0; }

    /* Pin the gear flush-right (auto-margin can't push past the edge) */
    .settings-container { margin-left: auto; }
    .settings-toggle-btn { margin-right: 0; }

    /* Keep the gear's dropdown anchored on-screen */
    .settings-dropdown {
        right: 0;
        left: auto;
        max-width: calc(100vw - 1.5rem);
    }

    /* Consistent menu-item styling for the theme item inside the gear */
    .setting-item.btn {
        width: 100%;
        justify-content: flex-start;
        gap: 0.6rem;
        padding: 0.55rem 0.6rem;
        border: none !important;
        box-shadow: none !important;
        border-radius: 0.5rem;
        color: #334155;
        font-size: 0.875rem;
    }
    .setting-item.btn:hover { background: #f1f5f9; color: #1e293b; }
    .setting-item.btn svg { flex-shrink: 0; }
    .settings-divider {
        height: 1px;
        background: rgba(2,6,23,0.08);
        margin: 0.35rem 0;
    }
    html[data-theme='dark'] .setting-item.btn { color: #cbd5e1; }
    html[data-theme='dark'] .setting-item.btn:hover { background: rgba(255,255,255,0.06); color: #fff; }
    html[data-theme='dark'] .settings-divider { background: var(--color-border); }
}

/* Input dock */
html[data-theme='dark'] .input-box {
    background: linear-gradient(180deg, rgba(30,41,59,0.6) 0%, rgba(15,23,42,0.45) 100%);
    border-color: rgba(255,255,255,0.14) !important;
    box-shadow:
        0 8px 30px -8px rgba(0,0,0,0.5),
        inset 0 1px 0 0 rgba(255,255,255,0.16),
        inset 0 -1px 0 0 rgba(0,0,0,0.25);
}
html[data-theme='dark'] .input-box:focus-within {
    box-shadow:
        0 12px 32px -8px rgba(0,0,0,0.5),
        inset 0 1px 0 0 rgba(255,255,255,0.2),
        inset 0 -14px 22px -14px rgba(0,162,197,0.6);
}
html[data-theme='dark'] .form-control.user-input,
html[data-theme='dark'] .hero-input-group .form-control.user-input {
    color: #e5e7eb;
    border-color: var(--color-border);
}
html[data-theme='dark'] .form-control.user-input {
    background: transparent;
}
html[data-theme='dark'] .hero-input-group .form-control.user-input {
    background: transparent;
    border: none;
}
html[data-theme='dark'] .form-control.user-input::placeholder,
html[data-theme='dark'] .hero-input-group .form-control.user-input::placeholder { color: #94a3b8; }
html[data-theme='dark'] .form-control:focus { box-shadow: none !important; border-color: rgba(148,163,184,0.15) !important; }

/* Messages */
html[data-theme='dark'] .bot-message-bubble { background-color: #1e293b; color: #e5e7eb; border-color: transparent; box-shadow: 0 1px 4px rgba(0,0,0,0.2); }
html[data-theme='dark'] .user-message-bubble { background: linear-gradient(135deg, #0097b2 0%, #007c94 50%, #006577 100%); color: #fff; box-shadow: 0 4px 16px rgba(0,162,197,0.3), 0 1px 4px rgba(0,0,0,0.3); }
html[data-theme='dark'] .bot-message-bubble pre { background-color: #0f172a; color: #e5e7eb; }
html[data-theme='dark'] .bot-message-bubble code { background-color: #0f172a; color: var(--color-tertiary); }
html[data-theme='dark'] .bot-message-bubble a { color: var(--color-quaternary); }

/* Scrollbar */
html[data-theme='dark'] ::-webkit-scrollbar-track { background: #0b1220; }
html[data-theme='dark'] ::-webkit-scrollbar-thumb { background: linear-gradient(180deg, #334155, #475569); }

/* Sessions overlay */
html[data-theme='dark'] .sessions-overlay { background: #0f172a; border-color: var(--color-border); box-shadow: 4px 0 20px rgba(0,0,0,0.4); }
html[data-theme='dark'] .sessions-overlay .overlay-header { background: #0f172a; box-shadow: 0 1px 0 rgba(148,163,184,0.1); }
html[data-theme='dark'] .sessions-overlay .list-group-item:not(.active):hover { background-color: rgba(255,255,255,0.04); }
html[data-theme='dark'] .sessions-overlay .list-group-item.active { background-color: rgba(0,162,197,0.12); color: #e5e7eb; border-left-color: var(--color-primary) !important; }
html[data-theme='dark'] .list-group-item .session-actions .kebab-btn { color: #bdcee6; }
html[data-theme='dark'] .list-group-item .session-actions .kebab-btn:hover { background: rgba(255,255,255,0.06); color: #e5e7eb; }
html[data-theme='dark'] .list-group-item .session-actions .session-menu { background: #0f172a; border-color: var(--color-border); box-shadow: 0 8px 24px rgba(0,0,0,0.5); }
html[data-theme='dark'] .list-group-item .session-actions .session-menu-item { color: #e5e7eb; }
html[data-theme='dark'] .list-group-item .session-actions .session-menu-item:hover { background: rgba(255,255,255,0.06); }
html[data-theme='dark'] .list-group-item .session-actions .session-menu-item.text-danger { color: #f87171; }
html[data-theme='dark'] .list-group-item .session-actions .session-menu-item.text-danger:hover { background: rgba(248,113,113,0.08); }

/* Modals */
html[data-theme='dark'] .rename-modal-dialog,
html[data-theme='dark'] .delete-modal-dialog,
html[data-theme='dark'] .login-card {
    background: #0f172a;
    border-color: var(--color-border);
    box-shadow: 0 18px 40px rgba(0,0,0,0.6);
}
html[data-theme='dark'] .login-card h5, html[data-theme='dark'] .login-card .card-title { color: var(--color-quaternary); }
html[data-theme='dark'] .login-card .form-control { background-color: #0b1220; border-color: var(--color-border); color: #e5e7eb; }
html[data-theme='dark'] .login-card .form-control::placeholder { color: #94a3b8; }
html[data-theme='dark'] .login-card .form-control:focus { border-color: rgba(13,110,253,.45); box-shadow: 0 0 0 .2rem rgba(13,110,253,.28) !important; }
html[data-theme='dark'] .login-card #login-submit, html[data-theme='dark'] .login-card .btn-primary { background-color: var(--color-primary); border-color: var(--color-primary); color: #fff; box-shadow: 0 6px 20px rgba(0,162,197,0.35); }
html[data-theme='dark'] .custom-primary-btn { background-color: var(--color-primary); border-color: var(--color-primary); color: #fff; }
html[data-theme='dark'] .custom-secondary-btn { background-color: transparent; border-color: var(--color-primary); color: var(--color-primary); }
html[data-theme='dark'] .custom-secondary-btn:hover { background-color: rgba(0,162,197,0.15); }
html[data-theme='dark'] .login-card .google-btn { background-color: #131314; border-color: #8e918f; color: #e3e3e3; }
html[data-theme='dark'] .login-card .google-btn:hover { background-color: #1c1d1e; color: #e3e3e3; }
html[data-theme='dark'] .login-divider { color: #64748b; }
html[data-theme='dark'] .login-divider::before,
html[data-theme='dark'] .login-divider::after { background: rgba(148,163,184,0.25); }
html[data-theme='dark'] #login-error { color: var(--color-tertiary); }
/* Dark overlay clarity */
html[data-theme='dark'] .rename-modal-overlay,
html[data-theme='dark'] .delete-modal-overlay {
    background: rgba(2,6,23,0.6);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}

/* Toasts */
html[data-theme='dark'] .popup-notification { box-shadow: 0 10px 24px rgba(0,0,0,0.6); }

/* Dark mode keeps the same theme-colored comet glow; brighten slightly for contrast */
html[data-theme='dark'] .bot-message-bubble.shimmer-background::before {
    opacity: 0.9 !important;
}
html[data-theme='dark'] .shimmer-background .status-text {
    color: #c8dce4 !important;
}

/* ==========================
     Dark Mode – Readability Fixes
     ========================== */
/* Hero overlay text */
html[data-theme='dark'] .hero-title { color: #cbd5e1; }
html[data-theme='dark'] .hero-heading { color: #e5e7eb; }
html[data-theme='dark'] .hero-description { color: #94a3b8; }
html[data-theme='dark'] .hero-desc-lead { color: #e2e8f0; }
html[data-theme='dark'] .hero-desc-sub { color: #94a3b8; }
html[data-theme='dark'] .hero-overlay .hero-content { color: #e5e7eb; }
html[data-theme='dark'] .hero-input-group {
    background: rgba(30,41,59,0.6);
    border-color: var(--color-border);
}
html[data-theme='dark'] .hero-input-group:focus-within {
    background: rgba(30,41,59,0.85);
    border-color: rgba(0,162,197,0.45);
}
html[data-theme='dark'] .hero-icon-glow {
    box-shadow: 0 0 10px 3px rgba(0,162,197,0.5);
}
html[data-theme='dark'] .orbitai-icon-border-arc {
    filter: blur(4px) brightness(1.15);
}

/* Textarea focus background should not turn white in dark */
html[data-theme='dark'] .form-control.user-input:focus {
    background: rgba(30,41,59,0.75) !important; /* slate-800 with alpha */
    color: #e5e7eb;
}
/* Bottom dock: the rule above must not apply when the field is empty — keep it
   transparent glass while empty (even on focus), solid only once text is typed. */
html[data-theme='dark'] .user-input-bottom:placeholder-shown:focus {
    background: transparent !important;
}
html[data-theme='dark'] .user-input-bottom:not(:placeholder-shown):focus {
    background: #1e293b !important;
}
html[data-theme='dark'] .hero-input-group .form-control.user-input:focus {
    background: transparent !important;
    color: #e5e7eb;
}

/* Bot message bubble contrast and separation */
html[data-theme='dark'] .bot-message-bubble {
    background-color: #0e1726;
    border: 1px solid transparent;
    background-image: linear-gradient(#0e1726, #0e1726), linear-gradient(135deg, rgba(0,162,197,0.35), rgba(34,174,86,0.35), rgba(13,110,253,0.35));
    background-origin: border-box;
    background-clip: padding-box, border-box;
}
html[data-theme='dark'] .user-message-bubble {
    border: 1px solid rgba(255,255,255,0.1);
}

/* Card header text and controls */
html[data-theme='dark'] .card-header { color: #e5e7eb; }
html[data-theme='dark'] .card-header .text-secondary { color: #cbd5e1 !important; }
html[data-theme='dark'] .card-header .btn-link { color: #cbd5e1; }
html[data-theme='dark'] .card-header .btn-link:hover { color: #ffffff; }

/* Sessions overlay text colors */
html[data-theme='dark'] .sessions-overlay { color: #e5e7eb; }
html[data-theme='dark'] .sessions-overlay .overlay-header h6 { color: #e5e7eb; }
html[data-theme='dark'] .sessions-overlay .list-group-item { color: #e5e7eb; background: transparent; }
html[data-theme='dark'] .sessions-overlay .list-group-item .text-muted { color: #9aa4b2 !important; }
html[data-theme='dark'] .sessions-overlay .list-group-item.active { color: #ffffff; }
html[data-theme='dark'] .sessions-overlay .list-group-item.active .text-muted { color: rgba(255,255,255,0.9) !important; }
html[data-theme='dark'] .sessions-overlay .list-group-item:not(.active):hover { background-color: rgba(255,255,255,0.05); }

/* ==========================
     Dark Mode – Additional Fixes
     ========================== */
/* Session list items borders and backgrounds */
html[data-theme='dark'] .sessions-overlay .list-group-item {
    background: transparent;
    border: none;
}
html[data-theme='dark'] .sessions-overlay .list-group-item.active {
    border-color: transparent !important;
    background: rgba(0,162,197,0.12);
    color: #e5e7eb;
    border-left: 3px solid var(--color-primary) !important;
}
html[data-theme='dark'] .sessions-overlay .list-group-item:not(.active):hover {
    background-color: rgba(255,255,255,0.04) !important;
}

/* Bot bubble higher contrast vs. background */
html[data-theme='dark'] .bot-message-bubble {
    background-color: #1f2937;
    background-image: linear-gradient(#1f2937, #1f2937), linear-gradient(135deg, rgba(0,162,197,0.35), rgba(34,174,86,0.35), rgba(13,110,253,0.35));
    background-origin: border-box;
    background-clip: padding-box, border-box;
    border-color: transparent;
}

/* Rename input should not be white */
html[data-theme='dark'] .rename-modal-dialog .form-control {
    background-color: #0b1220;
    color: #e5e7eb;
    border: 1px solid var(--color-border);
}
html[data-theme='dark'] .rename-modal-dialog .form-control::placeholder {
    color: #94a3b8;
}

/* Delete overlay bottom text visibility */
html[data-theme='dark'] .delete-modal-dialog {
    color: #e5e7eb;
}
html[data-theme='dark'] .delete-modal-dialog .text-muted {
    color: #9aa4b2 !important;
}

/* Close buttons outline removal and visibility */
#close-sessions-overlay:focus, #rename-close:focus, #delete-close:focus { outline: none !important; box-shadow: none !important; }
html[data-theme='dark'] #close-sessions-overlay,
html[data-theme='dark'] #rename-close,
html[data-theme='dark'] #delete-close {
    color: #cbd5e1;
    border-color: var(--color-border);
    background: transparent;
}
html[data-theme='dark'] #close-sessions-overlay:hover,
html[data-theme='dark'] #rename-close:hover,
html[data-theme='dark'] #delete-close:hover { background: rgba(255,255,255,0.06); }

/* Session list (history) button icon visibility */
html[data-theme='dark'] #history-btn img { filter: invert(1); }

/* User message bubble refinement for dark mode */
html[data-theme='dark'] .user-message-bubble {
    background: linear-gradient(135deg, #0097b2 0%, #007c94 50%, #006577 100%);
    color: #f8fafc;
    border-color: rgba(255,255,255,0.1);
    box-shadow: 0 4px 16px rgba(0,162,197,0.3), 0 1px 4px rgba(0,0,0,0.3);
}
html[data-theme='dark'] .user-message-bubble p,
html[data-theme='dark'] .user-message-bubble a { color: #f8fafc; }
html[data-theme='dark'] .user-message-bubble a { text-decoration: underline; }
/* ==========================
     Map Widget – Plus Button & Menu
     ========================== */
.input-plus-wrapper {
    display: inline-flex;
    align-items: center;
}
.plus-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50% !important;
    background: transparent;
    color: var(--color-primary);
    border: 1px solid transparent;
    transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease, transform 160ms ease;
    flex-shrink: 0;
}
.plus-btn:hover {
    background: rgba(0,162,197,0.10);
    border-color: rgba(0,162,197,0.18);
}
.plus-btn.active {
    background: rgba(0,162,197,0.15);
    border-color: rgba(0,162,197,0.3);
    transform: rotate(45deg);
}
html[data-theme='dark'] .plus-btn { color: var(--color-primary); }
html[data-theme='dark'] .plus-btn:hover { background: rgba(0,162,197,0.15); }

.plus-menu {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    min-width: 160px;
    background: var(--color-card, #fff);
    border: 1px solid var(--color-border, rgba(0,0,0,0.1));
    border-radius: 0.625rem;
    box-shadow: var(--shadow-md, 0 10px 25px rgba(2,6,23,0.12));
    padding: 4px 0;
    z-index: 1500;
    animation: scaleIn 140ms ease both;
}
html[data-theme='dark'] .plus-menu {
    background: #0f172a;
    border-color: var(--color-border);
    box-shadow: 0 10px 30px rgba(0,0,0,0.45);
}
.plus-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    background: transparent;
    border: none;
    text-align: left;
    padding: 8px 14px;
    font-size: 0.875rem;
    color: #212529;
    cursor: pointer;
    border-radius: 0;
    transition: background-color 120ms ease;
}
.plus-menu-item:hover { background: rgba(0,162,197,0.08); }
html[data-theme='dark'] .plus-menu-item { color: #e5e7eb; }
html[data-theme='dark'] .plus-menu-item:hover { background: rgba(255,255,255,0.06); }
.plus-menu-item svg { color: var(--color-primary); flex-shrink: 0; }

/* Location badge inside input area */
.location-badge {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    background: linear-gradient(135deg, rgba(0,162,197,0.42), rgba(34,174,86,0.38));
    -webkit-backdrop-filter: blur(12px) saturate(1.1);
    backdrop-filter: blur(12px) saturate(1.1);
    color: #ffffff;
    border: 1px solid rgba(0,162,197,0.28);
    border-radius: 1rem;
    padding: 0.5rem 0.75rem 0.5rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    margin-left: 0.5rem;
    max-width: min(360px, calc(100% - 1rem));
    animation: scaleIn 160ms ease both;
    box-shadow: 0 10px 24px rgba(15,23,42,0.08);
}

#bottom-location-badge {
    position: absolute;
    left: 0.5rem;
    bottom: calc(100% + 0.5rem);
    margin: 0;
    width: fit-content;
    max-width: min(360px, calc(100% - 1rem));
    z-index: 3;
    background: linear-gradient(135deg, rgba(0,162,197,0.76), rgba(34,174,86,0.68));
}

.location-badge-thumb {
    width: 46px;
    height: 46px;
    border-radius: 0.85rem;
    overflow: hidden;
    flex-shrink: 0;
    background: rgba(255,255,255,0.75);
    border: 1px solid rgba(255,255,255,0.75);
}
.location-badge-thumb img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}
.location-badge-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    flex: 1 1 auto;
}
.location-badge-title {
    color: #ffffff;
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.1;
}
.location-badge-meta {
    color: rgba(255,255,255,0.92);
    font-size: 0.7rem;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.location-badge-remove {
    background: rgba(255,255,255,0.75);
    border: none;
    padding: 0;
    margin-left: auto;
    font-size: 0.7rem;
    line-height: 1;
    color: #0f172a;
    opacity: 0.85;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    transition: opacity 120ms ease, background-color 120ms ease;
}
.location-badge-remove:hover { opacity: 1; background: rgba(0,162,197,0.2); }
html[data-theme='dark'] .location-badge {
    background: linear-gradient(135deg, rgba(0,162,197,0.28), rgba(34,174,86,0.26));
    border-color: rgba(0,162,197,0.38);
    color: #e2f5fb;
    box-shadow: 0 14px 28px rgba(2,6,23,0.32);
}
html[data-theme='dark'] .location-badge-thumb {
    background: rgba(15,23,42,0.8);
    border-color: rgba(148,163,184,0.18);
}
html[data-theme='dark'] .location-badge-title {
    color: #ffffff;
}
html[data-theme='dark'] .location-badge-meta {
    color: rgba(255,255,255,0.9);
}
html[data-theme='dark'] .location-badge-remove {
    background: rgba(15,23,42,0.7);
    color: #e2e8f0;
}

html[data-theme='dark'] #bottom-location-badge {
    background: linear-gradient(135deg, rgba(0,162,197,0.48), rgba(34,174,86,0.42));
    box-shadow: 0 14px 28px rgba(2,6,23,0.32);
}

/* Hero location badge sits above the input, in normal block flow */
#hero-location-badge {
    position: static;
    /* align left edge with the textarea start (offset by plus-btn width 40px) */
    margin-left: 40px;
    margin-top: 0.5rem;
    margin-bottom: 0;
    width: fit-content;
    max-width: calc(100% - 40px);
    background: linear-gradient(135deg, rgba(0,162,197,0.76), rgba(34,174,86,0.68));
}

/* ==========================
     Map Widget – Modal Overlay
     ========================== */
.map-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.55);
    display: none;
    align-items: flex-end;
    justify-content: center;
    z-index: 5000;
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
    padding: 1rem;
    overflow-y: auto;
}
.map-modal-overlay.open {
    display: flex;
    align-items: center;
}
.map-modal-dialog {
    background: var(--color-card, #fff);
    width: min(96vw, 860px);
    max-height: min(92dvh, calc(100dvh - 2rem));
    border-radius: 1rem;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 60px rgba(2,6,23,0.22);
    border: 1px solid var(--color-border, rgba(0,0,0,0.08));
    animation: scaleIn 200ms ease both;
}
html[data-theme='dark'] .map-modal-dialog {
    background: #0f172a;
    border-color: var(--color-border);
    box-shadow: 0 24px 60px rgba(0,0,0,0.55);
}
.map-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--color-border, rgba(0,0,0,0.08));
    background: rgba(255,255,255,0.96);
    flex-shrink: 0;
}
html[data-theme='dark'] .map-modal-header {
    background: rgba(15,23,42,0.96);
    border-bottom-color: var(--color-border);
    color: #e5e7eb;
}
.map-modal-instructions {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    color: var(--color-muted, #64748b);
    background: rgba(0,162,197,0.04);
    border-bottom: 1px solid var(--color-border, rgba(0,0,0,0.06));
    flex-shrink: 0;
}
html[data-theme='dark'] .map-modal-instructions {
    background: rgba(0,162,197,0.06);
    border-bottom-color: var(--color-border);
}
.map-search-overlay {
    position: absolute;
    top: 0.875rem;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    max-width: 32rem;
    z-index: 720;
    pointer-events: none;
}
.map-search-row {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    pointer-events: auto;
}
.map-search-input-wrap {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
}
.map-search-lens {
    position: absolute;
    top: 50%;
    left: 0.7rem;
    transform: translateY(-50%);
    color: #94a3b8;
    display: flex;
    align-items: center;
    pointer-events: none;
}
.map-search-input {
    width: 100%;
    height: 2.25rem;
    border-radius: 999px;
    border: 1px solid rgba(100,116,139,0.22);
    padding: 0 2.5rem 0 2.25rem;
    background: rgba(255,255,255,0.96);
    color: #0f172a;
    outline: none;
    font-size: 16px; /* ≥16px keeps iOS from zooming on focus */
    box-shadow: 0 8px 20px rgba(15,23,42,0.11);
}
.map-search-input:focus {
    border-color: rgba(0,162,197,0.45);
    box-shadow: 0 0 0 3px rgba(0,162,197,0.12), 0 10px 22px rgba(15,23,42,0.14);
}
.map-search-clear {
    position: absolute;
    top: 50%;
    right: 0.45rem;
    transform: translateY(-50%);
    width: 1.5rem;
    height: 1.5rem;
    border: 0;
    border-radius: 50%;
    background: rgba(148,163,184,0.16);
    color: #475569;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.map-search-clear:hover,
.map-search-clear:focus-visible {
    background: rgba(0,162,197,0.14);
    color: #0f172a;
}
.map-search-btn {
    display: none;
}
.map-search-results {
    margin-top: 0.5rem;
    border-radius: 1rem;
    background: rgba(255,255,255,0.96);
    box-shadow: 0 18px 38px rgba(15,23,42,0.16);
    border: 1px solid rgba(100,116,139,0.14);
    pointer-events: auto;
    overflow: hidden;
}
.map-search-results-scroll {
    display: grid;
    gap: 0.45rem;
    max-height: min(15rem, calc(100dvh - 20rem));
    overflow-y: auto;
    padding: 0.35rem;
}
.map-search-result {
    width: 100%;
    border: 1px solid rgba(100,116,139,0.16);
    background: rgba(248,250,252,0.96);
    border-radius: 0.85rem;
    padding: 0.65rem 0.8rem;
    text-align: left;
    transition: border-color 140ms, background 140ms, transform 140ms;
}
.map-search-result:hover,
.map-search-result:focus-visible,
.map-search-result.is-active {
    border-color: rgba(0,162,197,0.35);
    background: rgba(240,249,255,0.98);
    transform: translateY(-1px);
}
.map-search-result-title {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: #0f172a;
}
.map-search-result-meta {
    display: block;
    margin-top: 0.15rem;
    font-size: 0.75rem;
    color: #64748b;
}
.map-search-results-empty {
    font-size: 0.8rem;
    color: #64748b;
    padding: 0.45rem 0.55rem;
}
html[data-theme='dark'] .map-search-lens {
    color: #64748b;
}
html[data-theme='dark'] .map-search-input {
    background: rgba(15,23,42,0.9);
    color: #e2e8f0;
    border-color: rgba(148,163,184,0.24);
}
html[data-theme='dark'] .map-search-input::placeholder {
    color: #94a3b8;
}
html[data-theme='dark'] .map-search-clear {
    background: rgba(148,163,184,0.14);
    color: #cbd5e1;
}
html[data-theme='dark'] .map-search-clear:hover,
html[data-theme='dark'] .map-search-clear:focus-visible {
    background: rgba(0,162,197,0.18);
    color: #f8fafc;
}
html[data-theme='dark'] .map-search-results {
    background: rgba(15,23,42,0.94);
    border-color: rgba(148,163,184,0.14);
    box-shadow: 0 18px 38px rgba(0,0,0,0.36);
}
html[data-theme='dark'] .map-search-result {
    background: rgba(15,23,42,0.72);
    border-color: rgba(148,163,184,0.16);
}
html[data-theme='dark'] .map-search-result:hover,
html[data-theme='dark'] .map-search-result:focus-visible,
html[data-theme='dark'] .map-search-result.is-active {
    background: rgba(0,162,197,0.12);
    border-color: rgba(0,162,197,0.36);
}
html[data-theme='dark'] .map-search-result-title {
    color: #f8fafc;
}
html[data-theme='dark'] .map-search-result-meta,
html[data-theme='dark'] .map-search-results-empty {
    color: #94a3b8;
}
.map-container {
    flex: 1 1 auto;
    min-height: clamp(260px, 52dvh, 560px);
    position: relative;
    z-index: 1;
}
.map-container-shell {
    position: relative;
    flex: 1 1 auto;
    display: flex;
    min-height: 0;
}
.map-floating-actions {
    position: absolute;
    bottom: 2.5rem;
    right: 0.875rem;
    z-index: 700;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}
.map-floating-actions .btn {
    pointer-events: auto;
}
.map-floating-btn {
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    background: rgba(255,255,255,0.96);
    box-shadow: 0 2px 10px rgba(15,23,42,0.22);
    border: 1px solid rgba(0,162,197,0.28);
    color: var(--color-primary);
    transition: background 140ms, box-shadow 140ms;
}
.map-floating-btn:hover {
    background: #fff;
    box-shadow: 0 4px 16px rgba(0,162,197,0.28);
}
.map-floating-btn.is-loading {
    opacity: 0.7;
}
/* GPS button icon */
.map-gps-icon {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
}
/* Blue dot – current GPS location marker */
.map-gps-dot {
    width: 16px;
    height: 16px;
    background: #4285f4;
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 4px rgba(66,133,244,0.25);
    animation: gpsPulse 1.8s ease-out infinite;
}
@keyframes gpsPulse {
    0%   { box-shadow: 0 0 0 0 rgba(66,133,244,0.45); }
    70%  { box-shadow: 0 0 0 10px rgba(66,133,244,0); }
    100% { box-shadow: 0 0 0 0 rgba(66,133,244,0); }
}
html[data-theme='dark'] .map-floating-btn {
    background: rgba(15,23,42,0.9);
    border-color: rgba(0,162,197,0.4);
    color: #69d9f0;
}
html[data-theme='dark'] .map-floating-btn:hover {
    background: rgba(15,23,42,0.98);
}
/* Override Leaflet z-index so controls sit above our overlay */
.map-container .leaflet-top,
.map-container .leaflet-bottom { z-index: 500; }
.map-modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--color-border, rgba(0,0,0,0.08));
    background: rgba(255,255,255,0.96);
    flex-shrink: 0;
    gap: 0.75rem;
    flex-wrap: wrap;
}
html[data-theme='dark'] .map-modal-footer {
    background: rgba(15,23,42,0.96);
    border-top-color: var(--color-border);
}
.map-selection-info {
    font-size: 0.75rem;
    color: var(--color-muted, #64748b);
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.map-selection-info.is-error {
    color: #d63384;
}
/* .map-current-location-btn inherits all styling from .map-floating-btn */
.map-current-location-btn.is-loading {
    opacity: 0.7;
    animation: gpsPulse 1s ease-in-out infinite;
}

@media (max-height: 760px) {
    .map-modal-overlay {
        padding: 0.5rem;
        align-items: flex-start;
    }

    .map-modal-dialog {
        width: min(100vw, 860px);
        max-height: calc(100dvh - 1rem);
        border-radius: 0.875rem;
    }

    .map-modal-header {
        padding: 0.75rem 0.875rem;
    }

    .map-modal-instructions {
        padding: 0.45rem 0.875rem;
        font-size: 0.75rem;
    }

    .map-search-overlay {
        top: 0.625rem;
        left: 50%;
        transform: translateX(-50%);
        width: 80%;
    }

    .map-search-row {
        gap: 0.5rem;
    }

    .map-search-input {
        height: 2.1rem;
    }

    .map-search-results {
        max-height: min(12rem, calc(100dvh - 18rem));
    }

    .map-container {
        min-height: clamp(260px, 48dvh, 380px);
    }

    .map-modal-footer {
        padding: 0.625rem 0.875rem;
        align-items: flex-start;
    }

    .map-selection-info {
        max-width: none;
        white-space: normal;
    }
}

@media (min-height: 900px) {
    .map-modal-dialog {
        max-height: min(94dvh, calc(100dvh - 2rem));
    }

    .map-container {
        min-height: clamp(420px, 62dvh, 720px);
    }
}
.map-current-location-btn.is-loading {
    opacity: 0.8;
}
.map-modal-dialog .btn-outline-secondary {
    border-color: rgba(100,116,139,0.35);
    color: #334155;
}
.map-modal-dialog .btn-outline-secondary:hover,
.map-modal-dialog .btn-outline-secondary:focus-visible {
    background: rgba(148,163,184,0.14);
    border-color: rgba(100,116,139,0.45);
    color: #0f172a;
}
.map-mode-badge {
    font-size: 0.7rem;
    background: rgba(0,162,197,0.1);
    color: var(--color-primary);
    border: 1px solid rgba(0,162,197,0.2);
    border-radius: 2rem;
    padding: 2px 8px;
    font-weight: 500;
}
html[data-theme='dark'] .map-mode-badge { background: rgba(0,162,197,0.18); border-color: rgba(0,162,197,0.3); }
.map-close-btn { font-size: 0.8rem; }
html[data-theme='dark'] .map-selection-info.is-error {
    color: #ff8fbd;
}
html[data-theme='dark'] .map-modal-dialog .btn-outline-secondary {
    color: #e2e8f0;
    border-color: rgba(148,163,184,0.28);
    background: rgba(15,23,42,0.72);
}
html[data-theme='dark'] .map-modal-dialog .btn-outline-secondary:hover,
html[data-theme='dark'] .map-modal-dialog .btn-outline-secondary:focus-visible {
    background: rgba(148,163,184,0.16);
    border-color: rgba(148,163,184,0.45);
    color: #f8fafc;
}
/* .map-current-location-btn dark mode is covered by .map-floating-btn dark rules */

/* Ensure Leaflet draw toolbar styles are legible in dark mode */
html[data-theme='dark'] .leaflet-draw-toolbar a,
html[data-theme='dark'] .leaflet-bar a {
    background-color: #e2e8f0;
    color: #0f172a;
    border-color: #94a3b8;
    box-shadow: 0 6px 18px rgba(2,6,23,0.28);
}
html[data-theme='dark'] .leaflet-bar a:hover,
html[data-theme='dark'] .leaflet-draw-toolbar a:hover {
    background-color: #f8fafc;
}
html[data-theme='dark'] .leaflet-draw-toolbar a.leaflet-draw-toolbar-button-enabled,
html[data-theme='dark'] .leaflet-draw-toolbar a:focus-visible {
    background-color: #c8f1f8;
    border-color: rgba(0,162,197,0.55);
}
html[data-theme='dark'] .leaflet-draw-actions a {
    background: #0f172a;
    color: #e5e7eb;
    border-color: #334155;
}
html[data-theme='dark'] .leaflet-draw-actions a:hover,
html[data-theme='dark'] .leaflet-draw-actions a:focus-visible {
    background: #1e293b;
    color: #f8fafc;
}
html[data-theme='dark'] .leaflet-disabled {
    opacity: 0.55;
}
html[data-theme='dark'] .leaflet-popup-content-wrapper { background: #0f172a; color: #e5e7eb; }
html[data-theme='dark'] .leaflet-popup-tip { background: #0f172a; }

/* Hide dictation buttons when dictating – also hide the plus button */
.input-group.dictating #plus-btn,
.input-group.dictating #hero-plus-btn { opacity:0; visibility:hidden; pointer-events:none; transition:opacity 120ms ease; }
.input-group:not(.dictating) #plus-btn,
.input-group:not(.dictating) #hero-plus-btn { opacity:1; visibility:visible; }

/* Pr Widgets Wrapper */

.pr-widgets-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}
.pr-map-details-container {
    flex: 1 1 calc(50% - 8px);
    min-width: 320px;
    /* Header + map stack into one card; the shadow wraps the whole unit so
       the title doesn't read as a detached element above the map. */
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.3s ease;
}
/* PR Widget styles */
/* ── PR map: gradient-bordered card ──────────────────────────────────── */
/* A single brand-gradient border hugs the live map. */
.pr-widget-iframe-wrapper {
    position: relative;
    display: flex;
    /* Top corners squared: the title header caps the map here, so they read
       as one stacked card (gradient border stays on the map only). The card
       shadow lives on .pr-map-details-container so it wraps header + map. */
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

/* Crisp gradient border drawn as a masked ring laid OVER the map edge:
   exact thickness, covers the embedded map's own edge gutter, and follows
   the rounded corners (a plain border / ancestor clip can't do all three). */
.pr-widget-iframe-wrapper::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1.5px;                       /* border thickness */
    background: linear-gradient(135deg,
        rgba(var(--color-primary-rgb), 1) 0%,
        rgba(34, 174, 86, 0.95) 50%,
        rgba(13, 110, 253, 1) 100%);
    -webkit-mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
            mask-composite: exclude;
    pointer-events: none;
    z-index: 3;
}

/* Inner surface holding the iframe */
.pr-widget-frame {
    position: relative;
    flex: 1 1 auto;
    height: 480px;
    border-radius: inherit;
    overflow: hidden;
}
/* The embedded widget page has an ~8px body margin, so the map sits inset
   inside the iframe. Grow the iframe by that margin on every side and let
   .pr-widget-frame clip it: the blank margin is pushed out of view and the
   map fills to the border. No map content is lost — only the blank margin. */
.pr-widget-frame iframe {
    display: block;
    width: calc(100% + 16px);
    height: calc(100% + 16px);
    margin: -8px;
    border: 0;
}

/* Per-map header (shown when multiple maps are returned) — a brand-gradient
   "Map N" pill + the plot name, tied to the gradient border of the card. */
/* Title header capping the map: shares the map's width and sits flush on top
   of it (no gap), so the two stack into one card without the gradient border
   wrapping the title. */
.widget-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin: 0;
    padding: 0.5rem 0.7rem;
    font-size: 0.875rem;
    /* Faint brand wash (echoes the gradient border) over the card surface, so
       the header reads as a defined header in light mode instead of flat white. */
    background:
        linear-gradient(135deg,
            rgba(var(--color-primary-rgb), 0.10) 0%,
            rgba(34, 174, 86, 0.08) 50%,
            rgba(13, 110, 253, 0.10) 100%),
        var(--color-card);
    border: 1px solid var(--color-border);
    border-bottom: none;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}
/* Same brand wash in dark mode, at higher opacity so it reads over the
   dark card surface. */
html[data-theme='dark'] .widget-title {
    background:
        linear-gradient(135deg,
            rgba(var(--color-primary-rgb), 0.22) 0%,
            rgba(34, 174, 86, 0.16) 50%,
            rgba(13, 110, 253, 0.22) 100%),
        var(--color-card);
}
.widget-title-badge {
    flex-shrink: 0;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.02em;
    color: #fff;
    padding: 0.28rem 0.5rem;
    border-radius: var(--radius-pill);
    background: linear-gradient(135deg,
        rgba(var(--color-primary-rgb), 1) 0%,
        rgba(34, 174, 86, 0.95) 50%,
        rgba(13, 110, 253, 1) 100%);
}
.widget-title-name {
    min-width: 0;
    flex: 0 1 auto;
    font-weight: 600;
    color: #212529;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
html[data-theme='dark'] .widget-title-name {
    color: #e5e7eb;
}

.pr-widget-info {
    --pr-info-bg: rgba(44, 44, 44, 0.85);
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
    width: fit-content;
    white-space: pre-line;
    background-color: var(--pr-info-bg);
    border-color: var(--pr-info-bg);
    color: #fff;
    border-radius: 6px;
    padding: 0.5rem;
    font-size: 0.75rem;
}

html[data-theme='dark'] .pr-widget-iframe-wrapper {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* ==========================
   Regional map & image artifacts (regional_metadata)
   Ported from llm-widget: brand-gradient map card + glass fullscreen control,
   inline chat images, and the fullscreen image viewer with zoom/pan.
   ========================== */
.map-iframe-wrapper {
    position: relative;
    display: flex;
    padding: 1.5px;                       /* gradient border thickness */
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg,
        rgba(var(--color-primary-rgb), 1) 0%,
        rgba(34, 174, 86, 0.95) 50%,
        rgba(13, 110, 253, 1) 100%);
}

/* Inner surface holding the iframe — clips the map to the rounded border */
.map-frame {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    border-radius: calc(var(--radius-lg) - 1.5px);
    overflow: hidden;
    background: var(--color-card);
}
.map-frame iframe {
    display: block;
    width: 100%;
    border: 0;
    border-radius: inherit;
    background: var(--color-card);
}
/* Crisp hairline bevel over the map edge, separating it from the border */
.map-frame::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4);
    z-index: 1;
}
html[data-theme='dark'] .map-frame::after {
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}

/* Floating glass control over the map */
.fullscreen-btn {
    position: absolute;
    top: 0.9rem;
    left: 0.9rem;
    right: auto;
    z-index: 3;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    color: #1e293b;
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.9);
    border-radius: var(--radius-pill);
    cursor: pointer;
    line-height: 0;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 180ms ease, background-color 180ms ease, color 180ms ease, border-color 180ms ease;
}
.fullscreen-btn svg { display: block; }
.fullscreen-btn:hover { box-shadow: var(--shadow-md); background: var(--color-primary); color: #fff; border-color: transparent; }

/* Dark theme: glass control adapts to the dark surface */
html[data-theme='dark'] .fullscreen-btn {
    color: #e2e8f0;
    background: rgba(15, 23, 42, 0.6);
    border-color: rgba(148, 163, 184, 0.28);
}
html[data-theme='dark'] .fullscreen-btn:hover { background: var(--color-primary); color: #fff; border-color: transparent; }

/* Map card fills the screen cleanly while in fullscreen */
.map-iframe-wrapper:fullscreen { border-radius: 0; padding: 0; background: var(--color-card); box-shadow: none; }
.map-iframe-wrapper:fullscreen .map-frame { padding: 0; border-radius: 0; }
.map-iframe-wrapper:fullscreen iframe { height: 100%; border-radius: 0; }

.image-clickable {
    cursor: pointer;
}

/* Inline chat image: same brand-gradient border as the regional map card.
   Two background layers — gradient on the border-box, card colour on the
   padding-box — paint a 1.5px gradient ring around a single <img>. */
.chat-inline-image {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    border: 1.5px solid transparent;      /* gradient border thickness */
    border-radius: var(--radius-lg);
    background:
        linear-gradient(var(--color-card, #fff), var(--color-card, #fff)) padding-box,
        linear-gradient(135deg,
            rgba(var(--color-primary-rgb), 1) 0%,
            rgba(34, 174, 86, 0.95) 50%,
            rgba(13, 110, 253, 1) 100%) border-box;
    transition: transform 200ms ease;
}

/* Subtle lift cue that the image is clickable (translate stays crisp;
   scaling a raster image would interpolate its pixels and blur it) */
.chat-inline-image:hover {
    transform: translateY(-2px);
}

html[data-theme='dark'] .chat-inline-image {
    background:
        linear-gradient(#1e293b, #1e293b) padding-box,
        linear-gradient(135deg,
            rgba(var(--color-primary-rgb), 1) 0%,
            rgba(34, 174, 86, 0.95) 50%,
            rgba(13, 110, 253, 1) 100%) border-box;
}

/* Fullscreen image viewer overlay */
.image-fullscreen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
    cursor: pointer;
}

.image-fullscreen-overlay.show {
    opacity: 1;
}

.image-fullscreen-container {
    position: relative;
    max-width: 95vw;
    max-height: 95vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-fullscreen-img {
    max-width: 95vw;
    max-height: 95vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    cursor: default;
    transition: transform 0.2s ease-out;
    transform-origin: center center;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    -webkit-touch-callout: none;
}

.image-fullscreen-img.zoomed {
    cursor: grab;
}

.image-fullscreen-img.zoomed:active,
.image-fullscreen-img.dragging {
    cursor: grabbing !important;
    transition: none; /* Disable transition during drag for immediate response */
}

.image-fullscreen-controls {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: row;
    gap: 8px;
    z-index: 10002;
}

.zoom-control-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 16px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    color: #333;
    transition: background 0.2s ease, transform 0.2s ease;
}

.zoom-control-btn:hover {
    background: #f8f9fa;
    transform: scale(1.1);
}

.zoom-control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.image-zoom-indicator {
    position: fixed;
    bottom: 70px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 6px 10px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 10002;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.image-zoom-indicator.show {
    opacity: 1;
}

.image-fullscreen-close {
    position: fixed;
    top: 40px;
    right: 20px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 16px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    z-index: 10001;
    color: #333;
    transition: background 0.2s ease, transform 0.2s ease;
}

.image-fullscreen-close:hover {
    background: #f8f9fa;
    transform: scale(1.1);
}

/* Dark mode adjustments */
html[data-theme='dark'] .image-fullscreen-close {
    background: #1e293b;
    color: #cbd5e1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

html[data-theme='dark'] .image-fullscreen-close:hover {
    background: #334155;
}

html[data-theme='dark'] .zoom-control-btn {
    background: #1e293b;
    color: #cbd5e1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

html[data-theme='dark'] .zoom-control-btn:hover {
    background: #334155;
}

html[data-theme='dark'] .image-zoom-indicator {
    background: rgba(30, 41, 59, 0.9);
    color: #cbd5e1;
}


@media print {
    html, body, #chat-card, #chat-container {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        margin: 0 !important;
        padding-inline: 0.25rem !important;
        width: 100% !important;
        height: auto !important;
    }
    body { margin: 0; height: auto !important; overflow: visible !important; background: var(--bs-body-bg); }
    #chat-window { height: auto !important; overflow: visible !important; }
    #chat-card { width: 297mm; margin: 1rem auto; height: auto !important; max-height: none !important; overflow: visible !important; }
    #chat-container { padding-inline: 1rem !important; height: auto !important; max-height: none !important; overflow: visible !important; overflow-y: visible !important; }
    /* no input box and tip in print view */
    #chat-card .input-box,
    #chat-card .input-tip, 
    #chat-card #history-btn,
    #chat-card #new-chat-btn,
    #chat-card #settings-container,
    #chat-card #theme-toggle-container,
    #chat-card .session-dropdown-arrow,
    #chat-card #download-pdf-btn,
    .table-export-btn {
        display: none !important;
    }
    .pr-widgets-wrapper {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    /* Regional map card and inline images: keep each on one page; hide the
       on-map fullscreen control in the printout. */
    .map-iframe-wrapper,
    .chat-inline-image {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    .fullscreen-btn {
        display: none !important;
    }
    /* The "Preparing PDF…" overlay is still in the DOM during window.print();
       keep it out of the printed output. */
    .print-prep-overlay {
        display: none !important;
    }
    /* Keep each map card (title header + map) together — never split the
       title from its map, or the map itself, across a page break. */
    .pr-map-details-container,
    .widget-title {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    .widget-title {
        break-after: avoid;
        page-break-after: avoid;
    }
    /* The map's gradient border is a full-size gradient rect carved into a
       thin ring via mask-composite. Print engines don't honor mask-composite,
       so the mask fails and the whole gradient fills over the map. Drop the
       masked pseudo-element and fall back to a plain border for print. */
    .pr-widget-iframe-wrapper::after {
        display: none !important;
    }
    .pr-widget-iframe-wrapper {
        border: 1.5px solid rgba(13, 110, 253, 0.6) !important;
    }
    @page {
        size: A4 landscape;
        margin: 0;
        padding: 0;
    }
}

/* Feedback modal */
.feedback-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.4);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    -webkit-backdrop-filter: blur(4px) saturate(120%);
    backdrop-filter: blur(4px) saturate(120%);
}
.feedback-modal-overlay.open { display: flex; }
.feedback-modal-dialog {
    border: 1px solid var(--color-border, rgba(0,0,0,0.1));
    background: #fff;
    width: min(92vw, 480px);
    border-radius: 0.75rem;
    padding: 1rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}
.feedback-modal-dialog .form-control {
    background-color: #f8fafc;
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 0.5rem;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}
.feedback-modal-dialog .form-control:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 .2rem rgba(0, 162, 197, .2) !important;
}
.feedback-modal-dialog .form-label {
    color: #374151;
    font-weight: 500;
}

/* Dark mode feedback modal */
html[data-theme='dark'] .feedback-modal-dialog {
    background: #0f172a;
    border-color: var(--color-border);
    box-shadow: 0 18px 40px rgba(0,0,0,0.6);
}
html[data-theme='dark'] .feedback-modal-dialog .form-control {
    background-color: #0b1220;
    border-color: var(--color-border);
    color: #e5e7eb;
}
html[data-theme='dark'] .feedback-modal-dialog .form-control::placeholder {
    color: #94a3b8;
}
html[data-theme='dark'] .feedback-modal-dialog .form-control:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 .2rem rgba(0, 162, 197, .28) !important;
}
html[data-theme='dark'] .feedback-modal-dialog .form-label {
    color: #cbd5e1;
}
html[data-theme='dark'] .feedback-modal-overlay {
    background: rgba(2,6,23,0.6);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}

/* === First-time onboarding: role / persona selection ===================== */
/* Options block, aligned under the bot bubble (avatar 43px + gap). Capped at a
   comfortable reading width — otherwise on wide screens (#chat-container spans
   the viewport minus 10vw) the 2-col grid stretches each card into a huge,
   mostly-empty rectangle. */
.onboarding-options {
    margin: -0.25rem 0 1.5rem 51px;
    max-width: 620px;
}
@media (max-width: 600px) {
    .onboarding-options { margin-left: 0; max-width: 100%; }
}

/* Hide the user + bot message avatars on phones and widen the bubbles into the
   reclaimed space. */
@media (max-width: 576px) {
    .avatar.user-avatar,
    .orbitai-icon-border { display: none !important; }

    .bot-message-bubble,
    .user-message-bubble { max-width: 95%; }

    /* Sharpen the sender-side corner to anchor each message to its side */
    .bot-message-bubble { border-top-left-radius: 0; }
    .user-message-bubble { border-bottom-right-radius: 0; }

    /* Avatars are hidden, so the copy/like/dislike buttons must re-anchor to the
       bubble edge instead of clearing the (now absent) avatar. */
    .chat-message.from-bot .message-copy-btn { left: 8px; }
    .chat-message.from-user .message-copy-btn { right: 6px; }
    .chat-message.from-bot .message-feedback-btn.like-btn { left: 34px; }
    .chat-message.from-bot .message-feedback-btn.dislike-btn { left: 60px; }

    /* With the wordmark gone, the header can be shorter — trim its vertical
       padding to give the chat more room. */
    .card-header { padding: 0.35rem 0.6rem 0.4rem !important; }

    /* Swap the full wordmark for the compact icon so the session title gets room.
       !important is needed to beat `html.embed-false .brand-orbit { display:inline }`. */
    .logo-container .brand-orbit { display: none !important; }
    .logo-container .brand-logo-icon { display: inline-block; }
    /* The compact icon is too narrow to sit above the "Powered by" caption
       without it overflowing into the title, so hide the caption here. */
    .logo-container .powered-by { display: none; }

    /* In the hero state there is no session title, so keep the full wordmark
       (and its caption) instead of the compact icon. */
    #chat-card.hero-active .logo-container .brand-orbit { display: inline-block !important; }
    #chat-card.hero-active .logo-container .brand-logo-icon { display: none; }
    #chat-card.hero-active .logo-container .powered-by { display: inline; }
    /* Wordmark is back in the hero, so restore the taller header (its "Powered by"
       caption sits below the logo and needs the bottom padding). */
    #chat-card.hero-active .card-header { padding: 0.5rem 0.6rem 0.85rem !important; }
}
.onboarding-option-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem;
}
@media (max-width: 520px) {
    .onboarding-option-grid { grid-template-columns: 1fr; }
}
.onboarding-option-card {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    width: 100%;
    text-align: left;
    padding: 0.8rem 0.9rem;
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: #0f172a;
    font: inherit;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease, background-color 160ms ease;
}
.onboarding-option-card:hover {
    border-color: var(--color-primary);
    box-shadow: 0 6px 18px rgba(0,162,197,0.16);
    transform: translateY(-1px);
}
.onboarding-option-card:focus-visible {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 0.16rem rgba(var(--color-primary-rgb), 0.25);
}
.onboarding-option-card.is-selected,
.onboarding-option-card.is-current {
    border-color: var(--color-primary);
    background: rgba(var(--color-primary-rgb), 0.06);
}
/* "Current" pill on the role the user already has saved. */
.onboarding-option-badge {
    flex-shrink: 0;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--color-primary);
    background: rgba(var(--color-primary-rgb), 0.12);
    border-radius: 999px;
    padding: 0.15rem 0.5rem;
}
.onboarding-option-icon {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    /* Solid tile + white glyph, matching the SmartFarm insight tiles. */
    color: #fff;
    background: var(--oc, var(--color-primary));
}
/* The SmartFarm icons have wide viewBoxes (e.g. 40×30), so give the glyph most
   of the 38px tile — at 20px they letterbox down and read too small. */
.onboarding-option-icon svg { width: 26px; height: 26px; }
/* Post-setup "explore next" quick actions reuse the hero category icon look:
   a soft brand-tint square with the glyph in its own color, smaller and lighter
   than the solid farm-setup tiles above. Mirrors .hero-category-btn .category-icon. */
.post-setup-grid .onboarding-option-icon {
    width: 32px;
    height: 32px;
    border-radius: 0.5rem;
    background: rgba(0,162,197,0.08);
    color: var(--color-primary);
}
.post-setup-grid .onboarding-option-icon svg { width: 18px; height: 18px; }
.onboarding-option-label {
    flex: 1 1 auto;
    font-weight: 600;
    font-size: 0.9rem;
    line-height: 1.25;
}
/* Multi-select feature cards: "Select one or more" hint + a check circle per
   card (empty ring → filled tick when selected). Single-select cards don't
   render these elements. */
.onboarding-option-hint-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin: 0 0 0.6rem;
}
.onboarding-option-hint {
    margin: 0;
    font-size: 0.78rem;
    color: var(--color-muted);
}
/* Checkbox-style "Select all" in the hint row — the ring fills with a tick
   when every card is selected (mirrors the per-card check circles). */
.farm-select-all {
    font: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    color: #0f172a;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}
.farm-select-all:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: 4px;
}
.farm-select-all-circle {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(100, 116, 139, 0.45);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: background .15s ease, border-color .15s ease;
}
.farm-select-all-circle svg { width: 10px; height: 10px; opacity: 0; transition: opacity .15s ease; }
.farm-select-all.all-on .farm-select-all-circle {
    background: var(--color-primary);
    border-color: var(--color-primary);
}
.farm-select-all.all-on .farm-select-all-circle svg { opacity: 1; }
.onboarding-options.locked .farm-select-all { display: none; }
html[data-theme='dark'] .farm-select-all { color: #e2e8f0; }
html[data-theme='dark'] .farm-select-all-circle { border-color: rgba(148, 163, 184, 0.5); }
.onboarding-option-check {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid rgba(100, 116, 139, 0.4);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: background .15s ease, border-color .15s ease;
}
.onboarding-option-check svg { width: 12px; height: 12px; opacity: 0; transition: opacity .15s ease; }
.onboarding-option-card.is-selected .onboarding-option-check {
    background: var(--color-primary);
    border-color: var(--color-primary);
}
.onboarding-option-card.is-selected .onboarding-option-check svg { opacity: 1; }
html[data-theme='dark'] .onboarding-option-check { border-color: rgba(148, 163, 184, 0.45); }
.onboarding-options.locked .onboarding-option-card { pointer-events: none; }
.onboarding-options.locked .onboarding-option-card:not(.is-selected) { opacity: 0.5; }

/* Sourcing Lead regional coverage, rendered inside the activation bubble:
   country + crop chips with the state-level rows behind a details expander.
   Color is the connective tissue — each crop keeps one hue everywhere (chip
   and per-row pill), countries take the brand teal. The .rc-cv-* variants set
   the bg/fg/border custom props that chips and pills consume. */
.rc-block { margin-top: 0.55rem; }
.rc-cv-violet { --rc-bg: rgba(139, 92, 246, 0.10); --rc-fg: #7c3aed; --rc-bd: rgba(139, 92, 246, 0.28); }
.rc-cv-green  { --rc-bg: rgba(34, 174, 86, 0.10);  --rc-fg: #16873f; --rc-bd: rgba(34, 174, 86, 0.28); }
.rc-cv-amber  { --rc-bg: rgba(245, 158, 11, 0.12); --rc-fg: #b45309; --rc-bd: rgba(245, 158, 11, 0.32); }
.rc-cv-rose   { --rc-bg: rgba(225, 29, 72, 0.09);  --rc-fg: #be123c; --rc-bd: rgba(225, 29, 72, 0.26); }
.rc-cv-blue   { --rc-bg: rgba(13, 110, 253, 0.09); --rc-fg: #1d4ed8; --rc-bd: rgba(13, 110, 253, 0.26); }
.rc-cv-teal   { --rc-bg: rgba(0, 162, 197, 0.09);  --rc-fg: #007e9a; --rc-bd: rgba(0, 162, 197, 0.22); }
html[data-theme='dark'] .rc-cv-violet { --rc-bg: rgba(139, 92, 246, 0.16); --rc-fg: #c4b5fd; --rc-bd: rgba(139, 92, 246, 0.42); }
html[data-theme='dark'] .rc-cv-green  { --rc-bg: rgba(34, 174, 86, 0.16);  --rc-fg: #6ee7a0; --rc-bd: rgba(34, 174, 86, 0.42); }
html[data-theme='dark'] .rc-cv-amber  { --rc-bg: rgba(245, 158, 11, 0.15); --rc-fg: #fcd34d; --rc-bd: rgba(245, 158, 11, 0.4); }
html[data-theme='dark'] .rc-cv-rose   { --rc-bg: rgba(244, 63, 94, 0.15);  --rc-fg: #fda4af; --rc-bd: rgba(244, 63, 94, 0.4); }
html[data-theme='dark'] .rc-cv-blue   { --rc-bg: rgba(13, 110, 253, 0.16); --rc-fg: #93c5fd; --rc-bd: rgba(13, 110, 253, 0.42); }
html[data-theme='dark'] .rc-cv-teal   { --rc-bg: rgba(0, 162, 197, 0.16);  --rc-fg: #67d6ee; --rc-bd: rgba(0, 162, 197, 0.38); }
.rc-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #64748b;
    margin: 0.85rem 0 0.35rem;
}
.rc-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.rc-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.24rem 0.62rem;
    border-radius: 999px;
    background: var(--rc-bg, rgba(2, 6, 23, 0.045));
    border: 1px solid var(--rc-bd, rgba(2, 6, 23, 0.06));
    color: var(--rc-fg, inherit);
}
.rc-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    background: currentColor;
    opacity: 0.8;
}
.rc-pills {
    display: inline-flex;
    gap: 0.3rem;
    flex-shrink: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.rc-pill {
    display: inline-flex;
    align-items: center;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.1rem 0.48rem;
    border-radius: 999px;
    white-space: nowrap;
    background: var(--rc-bg);
    color: var(--rc-fg);
}
.rc-regions { margin-top: 0.75rem; border-top: 1px solid rgba(2, 6, 23, 0.06); }
.rc-regions summary {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.6rem 0 0.15rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-primary);
    user-select: none;
}
.rc-regions summary::-webkit-details-marker { display: none; }
.rc-chev { display: inline-flex; transition: transform 0.15s ease; }
.rc-regions[open] .rc-chev { transform: rotate(90deg); }
.rc-country { padding: 0.55rem 0 0.2rem; }
.rc-country + .rc-country { border-top: 1px solid rgba(2, 6, 23, 0.06); }
.rc-country-name {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-weight: 700;
    font-size: 0.85rem;
    margin-bottom: 0.2rem;
}
.rc-state-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.26rem 0;
    font-size: 0.84rem;
}
html[data-theme='dark'] .rc-label { color: #94a3b8; }
html[data-theme='dark'] .rc-regions,
html[data-theme='dark'] .rc-country + .rc-country { border-color: rgba(148, 163, 184, 0.14); }
@media (max-width: 576px) {
    .rc-state-row { flex-direction: column; align-items: flex-start; gap: 0.15rem; }
    .rc-pills { justify-content: flex-start; }
}

/* Continue row under a multi-select feature choice (post area-audit). */
.farm-feature-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.75rem;
}
.farm-feature-actions .custom-primary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.onboarding-options.locked .farm-feature-actions { display: none; }

/* Status row: loading / error inside an options block or bot bubble. */
.onboarding-status {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--color-muted);
    font-size: 0.875rem;
}
.onboarding-status--error { color: #dc2626; }
.onboarding-spinner {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(var(--color-primary-rgb), 0.25);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    display: inline-block;
    animation: ob-spin 0.7s linear infinite;
}
@keyframes ob-spin { to { transform: rotate(360deg); } }
.onboarding-retry {
    margin-left: 0.4rem;
    border: 1px solid var(--color-primary);
    background: transparent;
    color: var(--color-primary);
    border-radius: var(--radius-sm);
    padding: 0.15rem 0.6rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 140ms ease, color 140ms ease;
}
.onboarding-retry:hover { background: var(--color-primary); color: #fff; }

/* "Coming soon" next-step card (placeholder for farm setup / Step 2). */
.onboarding-option-card.coming-soon {
    cursor: default;
    border-style: dashed;
    opacity: 0.85;
}
.onboarding-option-card.coming-soon:hover {
    transform: none;
    box-shadow: var(--shadow-sm);
    border-color: var(--color-border);
}
.coming-soon-badge {
    margin-left: auto;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-muted);
    background: rgba(100,116,139,0.12);
    border-radius: 999px;
    padding: 0.15rem 0.5rem;
    white-space: nowrap;
}

/* Farm-name step: suggestion chips + free-text input. */
.farm-name-block { display: flex; flex-direction: column; gap: 0.75rem; }
.farm-name-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.farm-name-chip {
    border: 1px solid var(--color-border);
    background: var(--color-card);
    color: #0f172a;
    border-radius: 999px;
    padding: 0.4rem 0.85rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease, background-color 140ms ease;
}
.farm-name-chip:hover {
    border-color: var(--color-primary);
    box-shadow: 0 4px 12px rgba(0,162,197,0.16);
    transform: translateY(-1px);
}
.farm-name-chip:focus-visible {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 0.16rem rgba(var(--color-primary-rgb), 0.25);
}
.farm-name-form {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
    max-width: 420px;
}
.farm-name-input {
    flex: 1 1 auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 0.5rem 0.75rem;
    font: inherit;
    font-size: 16px; /* ≥16px keeps iOS from zooming on focus */
    color: #0f172a;
    background: var(--color-card);
}
.farm-name-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 0.16rem rgba(var(--color-primary-rgb), 0.2);
}
.farm-name-save { white-space: nowrap; }
.onboarding-options.locked .farm-name-chip,
.onboarding-options.locked .farm-name-input,
.onboarding-options.locked .farm-name-save { pointer-events: none; opacity: 0.6; }

/* Crop / variety step: a two-step drill-down panel — the crop list first, then
   only the chosen crop's varieties, with an always-visible search scoped to
   the current step. The panel reuses the Tier-1 liquid-glass recipe (see
   LIQUID GLASS SURFACES) so it reads as floating UI inside the chat. */
.farm-crop-block { display: flex; flex-direction: column; gap: 0.6rem; max-width: none; }
.farm-crop-panel {
    display: flex;
    flex-direction: column;
    width: min(480px, 100%);
    border-radius: 18px;
    overflow: hidden;
    color: #0f172a;
    -webkit-backdrop-filter: blur(24px) saturate(190%);
    backdrop-filter: blur(24px) saturate(190%);
    background: linear-gradient(180deg, rgba(255,255,255,0.92), rgba(238,246,249,0.88));
    border: 1px solid rgba(255,255,255,0.7);
    box-shadow:
        0 16px 40px -10px rgba(2,6,23,0.3),
        inset 0 1px 0 0 rgba(255,255,255,0.95);
}
.farm-crop-head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.85rem 1rem 0;
    min-height: 34px;
}
.farm-crop-back {
    display: none;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    padding: 0;
    border-radius: 10px;
    border: 1px solid var(--color-border);
    background: var(--color-card);
    color: inherit;
    cursor: pointer;
    transition: background-color 140ms ease;
}
.farm-crop-back svg { width: 15px; height: 15px; }
.farm-crop-back:hover { background: rgba(var(--color-primary-rgb), 0.1); }
.farm-crop-back:focus-visible {
    outline: none;
    box-shadow: 0 0 0 0.16rem rgba(var(--color-primary-rgb), 0.25);
}
.farm-crop-panel.step2 .farm-crop-back { display: inline-flex; }
/* The crumb (selected crop's icon) only exists in step 2, next to the title. */
.farm-crop-crumb { display: none; }
.farm-crop-panel.step2 .farm-crop-crumb { display: inline-flex; }
.farm-crop-crumb .farm-crop-icon { width: 30px; height: 30px; border-radius: 9px; font-size: 15px; }
.farm-crop-head-text { min-width: 0; }
.farm-crop-title { font-weight: 600; font-size: 0.95rem; }
.farm-crop-sub { font-size: 0.76rem; color: var(--color-muted); margin-top: 1px; }
.farm-crop-search { position: relative; padding: 0.7rem 1rem 0.6rem; }
/* Direct child only — the clear button's own svg must stay inside its button. */
.farm-crop-search > svg {
    position: absolute;
    left: 1.85rem;
    top: 50%;
    transform: translateY(calc(-50% + 1px));
    width: 15px;
    height: 15px;
    color: var(--color-muted);
    pointer-events: none;
}
.farm-crop-search-input {
    width: 100%;
    border-radius: 12px;
    border: 1px solid var(--color-border);
    background: var(--color-card);
    color: inherit;
    padding: 0.55rem 0.75rem 0.55rem 2.35rem;
    font: inherit;
    font-size: 16px; /* ≥16px keeps iOS from zooming on focus */
    outline: none;
    transition: border-color 140ms ease, box-shadow 140ms ease;
}
.farm-crop-search-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.15);
}
.farm-crop-search-input::placeholder { color: var(--color-muted); }
/* Room for the clear (×) button on the right, mirroring the icon gutter. */
.farm-crop-search .farm-crop-search-input { padding-right: 2.3rem; }
.farm-crop-search-clear[hidden] { display: none; }
.farm-crop-search-clear {
    position: absolute;
    right: 1.45rem;
    top: 50%;
    transform: translateY(calc(-50% + 1px));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(100, 116, 139, 0.14);
    color: var(--color-muted);
    cursor: pointer;
    transition: background-color 130ms ease, color 130ms ease;
}
.farm-crop-search-clear svg { width: 11px; height: 11px; }
.farm-crop-search-clear:hover { background: rgba(100, 116, 139, 0.24); color: inherit; }
.farm-crop-search-clear:focus-visible {
    outline: none;
    box-shadow: 0 0 0 0.16rem rgba(var(--color-primary-rgb), 0.25);
}
html[data-theme='dark'] .farm-crop-search-clear { background: rgba(148, 163, 184, 0.18); }
html[data-theme='dark'] .farm-crop-search-clear:hover { background: rgba(148, 163, 184, 0.3); }
.farm-crop-list {
    overflow-y: auto;
    max-height: 320px;
    padding: 2px 0.6rem 0.75rem;
    scrollbar-width: thin;
}
.farm-crop-row,
.farm-variety-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    border: 0;
    background: transparent;
    color: inherit;
    border-radius: 12px;
    cursor: pointer;
    font: inherit;
    text-align: left;
    transition: background-color 130ms ease;
}
.farm-crop-row { padding: 0.6rem; }
.farm-variety-row { position: relative; padding: 0.6rem 0.75rem; font-size: 0.89rem; }
/* Hairline divider between variety rows; hidden around the hovered/focused row
   so the highlight pill reads as one clean shape. */
.farm-variety-row + .farm-variety-row::before {
    content: '';
    position: absolute;
    left: 3.5rem;
    right: 0.75rem;
    top: 0;
    height: 1px;
    background: var(--color-border);
    transition: opacity 130ms ease;
}
.farm-variety-row:hover::before,
.farm-variety-row:hover + .farm-variety-row::before,
.farm-variety-row:focus-visible::before,
.farm-variety-row:focus-visible + .farm-variety-row::before { opacity: 0; }
.farm-variety-initial {
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    border-radius: 50%;
    background: rgba(var(--color-primary-rgb), 0.12);
    border: 1px solid rgba(var(--color-primary-rgb), 0.2);
    color: var(--color-primary);
    font-size: 0.78rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.farm-variety-name { flex: 1; min-width: 0; font-weight: 500; overflow-wrap: anywhere; }
.farm-variety-mark {
    background: rgba(var(--color-primary-rgb), 0.22);
    color: inherit;
    border-radius: 3px;
    padding: 0 1px;
}
.farm-variety-pick {
    flex: 0 0 auto;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--color-primary);
    opacity: 0;
    transition: opacity 130ms ease;
}
.farm-variety-row:hover .farm-variety-pick,
.farm-variety-row:focus-visible .farm-variety-pick { opacity: 1; }
.farm-crop-row:hover, .farm-crop-row:focus-visible,
.farm-variety-row:hover, .farm-variety-row:focus-visible {
    background: rgba(var(--color-primary-rgb), 0.1);
    outline: none;
}
.farm-crop-icon {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 11px;
    background: rgba(var(--color-primary-rgb), 0.12);
    border: 1px solid rgba(var(--color-primary-rgb), 0.22);
    font-size: 19px; /* emoji glyph */
    line-height: 1;
}
.farm-crop-row-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.farm-crop-row-name { font-weight: 600; font-size: 0.9rem; }
.farm-crop-row-count { font-size: 0.76rem; color: var(--color-muted); margin-top: 1px; }
/* Shown when a search query matched a variety name but not the crop's own. */
.farm-crop-row-hint {
    font-size: 0.74rem;
    color: var(--color-primary);
    margin-top: 1px;
    overflow-wrap: anywhere;
}
.farm-crop-chev { color: var(--color-muted); flex: 0 0 auto; font-size: 1rem; line-height: 1; }
.farm-crop-empty {
    padding: 1.2rem 1rem;
    text-align: center;
    color: var(--color-muted);
    font-size: 0.85rem;
}
/* "Others" variety → inline name-it form replacing the list (search hidden). */
.farm-crop-panel.naming .farm-crop-search { display: none; }
.farm-crop-name-form {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 0.6rem 0.5rem 0.35rem;
}
.farm-crop-name-prompt { font-size: 0.88rem; }
/* The name input reuses the search-input skin but has no magnifier icon, so
   drop the icon gutter. */
.farm-crop-name-form .farm-crop-search-input { padding-left: 0.75rem; }
.farm-crop-name-save {
    align-self: flex-end;
    border: 1px solid var(--color-primary);
    background: var(--color-primary);
    color: #fff;
    border-radius: 10px;
    padding: 0.5rem 1rem;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: filter 140ms ease;
}
.farm-crop-name-save:hover { filter: brightness(1.06); }
.farm-crop-name-save:focus-visible {
    outline: none;
    box-shadow: 0 0 0 0.16rem rgba(var(--color-primary-rgb), 0.25);
}
.farm-crop-foot {
    padding: 0.5rem 1rem;
    font-size: 0.73rem;
    color: var(--color-muted);
    border-top: 1px solid var(--color-border);
    text-align: center;
}
.onboarding-options.locked .farm-crop-panel { pointer-events: none; opacity: 0.6; }

html[data-theme='dark'] .farm-crop-panel {
    color: #e2e8f0;
    background: linear-gradient(180deg, rgba(30,41,59,0.92), rgba(15,23,42,0.88));
    border: 1px solid rgba(255,255,255,0.14);
    box-shadow:
        0 16px 40px -10px rgba(0,0,0,0.6),
        inset 0 1px 0 0 rgba(255,255,255,0.16);
}
html[data-theme='dark'] .farm-crop-icon { background: rgba(255, 255, 255, 0.06); border-color: rgba(148, 163, 184, 0.16); }
html[data-theme='dark'] .farm-crop-back { background: rgba(255, 255, 255, 0.05); border-color: rgba(148, 163, 184, 0.22); }
html[data-theme='dark'] .farm-crop-search-input { background: rgba(255, 255, 255, 0.05); border-color: rgba(148, 163, 184, 0.22); }

/* Season + sowing-date steps. */
.onboarding-hint { color: var(--color-muted); font-weight: 500; font-size: 0.85em; }
.farm-season-skip {
    border-style: dashed;
    color: var(--color-muted);
}
.farm-date-block { display: flex; flex-direction: column; gap: 0.6rem; align-items: flex-start; }
.farm-date-error { font-size: 0.85rem; }

/* Custom inline calendar for the sowing-date step. */
.farm-calendar {
    width: 100%;
    max-width: 320px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-card);
    padding: 0.65rem;
    box-shadow: var(--shadow-sm);
}
.farm-cal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}
.farm-cal-head-selects { display: flex; gap: 0.35rem; }
.farm-cal-select {
    border: 1px solid var(--color-border);
    background: var(--color-card);
    color: #0f172a;
    border-radius: 8px;
    padding: 0.25rem 0.4rem;
    font: inherit;
    font-size: 16px; /* ≥16px keeps iOS from zooming on focus */
    font-weight: 600;
    cursor: pointer;
    max-width: 8.5rem;
}
.farm-cal-select:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 0.14rem rgba(var(--color-primary-rgb), 0.2); }
.farm-cal-nav {
    width: 28px;
    height: 28px;
    border: 1px solid var(--color-border);
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.15rem;
    line-height: 1;
    color: #0f172a;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}
.farm-cal-nav:hover:not(:disabled) { border-color: var(--color-primary); color: var(--color-primary); }
.farm-cal-nav:disabled { opacity: 0.35; cursor: default; }
.farm-cal-weekdays,
.farm-cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}
.farm-cal-weekdays span {
    text-align: center;
    font-size: 0.66rem;
    font-weight: 700;
    color: var(--color-muted);
    padding: 0.2rem 0;
}
.farm-cal-day {
    aspect-ratio: 1 / 1;
    border: 0;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    font: inherit;
    font-size: 0.8rem;
    color: #0f172a;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 120ms ease, color 120ms ease;
}
.farm-cal-day.is-blank { pointer-events: none; }
.farm-cal-day:hover:not(.is-disabled):not(.is-blank):not(.is-selected) { background: rgba(var(--color-primary-rgb), 0.12); }
.farm-cal-day.is-today { box-shadow: inset 0 0 0 1px var(--color-primary); font-weight: 700; }
.farm-cal-day.is-selected { background: var(--color-primary); color: #fff; font-weight: 700; }
.farm-cal-day.is-disabled { color: var(--color-muted); opacity: 0.4; cursor: default; }
.farm-cal-quick { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.farm-cal-footer { align-items: center; width: 100%; max-width: 320px; }
.farm-cal-selected { flex: 1 1 auto; font-size: 0.85rem; color: var(--color-muted); }
.farm-cal-selected.has-value { color: #0f172a; font-weight: 600; }
.onboarding-options.locked .farm-cal-day,
.onboarding-options.locked .farm-cal-nav,
.onboarding-options.locked .farm-cal-select,
.onboarding-options.locked .farm-cal-quick-chip { pointer-events: none; opacity: 0.6; }

html[data-theme='dark'] .farm-calendar {
    background: rgba(255,255,255,0.04);
    border-color: rgba(148,163,184,0.22);
}
html[data-theme='dark'] .farm-cal-nav,
html[data-theme='dark'] .farm-cal-day { color: #e2e8f0; }
html[data-theme='dark'] .farm-cal-select {
    background: #1e293b;
    border-color: rgba(148,163,184,0.22);
    color: #e2e8f0;
}
html[data-theme='dark'] .farm-cal-selected.has-value { color: #e2e8f0; }
html[data-theme='dark'] .farm-cal-day.is-selected { color: #fff; }

/* Resume-progress summary list (shown when a saved setup exists). */
.farm-progress-list {
    margin: 0.5rem 0 0;
    padding-left: 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.88rem;
}
.farm-progress-list li { line-height: 1.35; }

/* "Activating…" checklist shown while intelligence is being enabled. */
/* Selection-aware "activating" message: one row per chosen feature — its tile
   icon, the `activating` copy, and a spinner (polled) or green tick (instant). */
.farm-activating-rows {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 0.55rem 0;
}
.farm-activating-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.farm-activating-tile {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: var(--tc, var(--color-primary));
}
.farm-activating-tile svg { width: 19px; height: 19px; }
.farm-activating-label {
    flex: 1 1 auto;
    font-size: 0.86rem;
    font-weight: 600;
}
.farm-activating-status {
    flex-shrink: 0;
    font-size: 0.74rem;
    color: var(--color-muted);
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}
.farm-activating-status.on {
    color: var(--color-secondary);
    font-weight: 600;
}
.farm-activating-status.warn {
    color: #dc2626;
    font-weight: 600;
}
html[data-theme='dark'] .farm-activating-status.warn { color: #f87171; }
.farm-activating-spin {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    border: 2px solid rgba(var(--color-primary-rgb), 0.25);
    border-top-color: var(--color-primary);
    animation: farm-activating-spin 1s linear infinite;
}
@keyframes farm-activating-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
    .farm-activating-spin { animation: none; }
}
.farm-activating-tick {
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: var(--color-secondary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.farm-activating-tick svg { width: 8px; height: 8px; }
.farm-activating-note {
    font-size: 0.82rem;
    color: var(--color-muted);
}

html[data-theme='dark'] .farm-name-chip,
html[data-theme='dark'] .farm-name-input {
    background: rgba(255,255,255,0.04);
    border-color: rgba(148,163,184,0.22);
    color: #e2e8f0;
}
html[data-theme='dark'] .farm-name-chip:hover { border-color: var(--color-primary); }

/* Dark theme */
html[data-theme='dark'] .onboarding-option-card {
    background: rgba(255,255,255,0.04);
    border-color: rgba(148,163,184,0.22);
    color: #e2e8f0;
}
html[data-theme='dark'] .onboarding-option-card:hover {
    border-color: var(--color-primary);
}
html[data-theme='dark'] .onboarding-option-card.is-selected,
html[data-theme='dark'] .onboarding-option-card.is-current {
    background: rgba(var(--color-primary-rgb), 0.16);
    border-color: var(--color-primary);
}
html[data-theme='dark'] .onboarding-option-badge {
    background: rgba(var(--color-primary-rgb), 0.22);
}
html[data-theme='dark'] .coming-soon-badge {
    background: rgba(148,163,184,0.18);
    color: #cbd5e1;
}

/* === "View my farms" — plot cards ======================================== */
.farm-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 0.75rem;
}
.farm-card {
    display: flex;
    flex-direction: column;
    background: var(--color-card, #fff);
    border: 1px solid var(--color-border, rgba(2,6,23,0.08));
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 160ms ease, border-color 160ms ease, transform 160ms ease;
}
.farm-card:hover {
    box-shadow: var(--shadow-md);
    border-color: rgba(var(--color-primary-rgb), 0.45);
    transform: translateY(-1px);
}
.farm-card-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: rgba(var(--color-primary-rgb), 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.farm-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.farm-card-thumb.is-empty {
    color: rgba(var(--color-primary-rgb), 0.45);
}
.farm-card-thumb.is-empty svg { width: 38px; height: 38px; }
.farm-thumb-loading { display: flex; align-items: center; justify-content: center; }

/* Boundary screenshot shown in the "boundary is set" chat bubble. Capped so it
   reads as a contained preview rather than filling the whole bubble width. */
.boundary-thumb {
    width: 100%;
    max-width: 340px;
    aspect-ratio: 16 / 9;
    background: rgba(var(--color-primary-rgb), 0.06);
    overflow: hidden;
    border-radius: 0.7rem;
    margin: 0.7rem 0 0.2rem;
}
.boundary-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
html[data-theme='dark'] .boundary-thumb { background: rgba(255,255,255,0.05); }

.farm-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem 0.85rem 0.85rem;
}
.farm-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
}
.farm-card-title {
    font-weight: 600;
    font-size: 0.92rem;
    color: #0f172a;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}
.farm-card-rows {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
.farm-card-row {
    display: flex;
    gap: 0.5rem;
    font-size: 0.82rem;
    line-height: 1.3;
}
.farm-card-label {
    flex: 0 0 5.5rem;
    color: var(--color-muted);
}
.farm-card-value {
    flex: 1 1 auto;
    color: #334155;
    font-weight: 500;
    word-break: break-word;
}

/* Feature status pills (intelligence + weather), stacked on the card head */
.farm-card-badges {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.3rem;
    flex-shrink: 0;
}
.farm-badge {
    flex-shrink: 0;
    font-size: 0.68rem;
    font-weight: 600;
    line-height: 1;
    padding: 0.3rem 0.5rem;
    border-radius: var(--radius-pill);
    white-space: nowrap;
}
.farm-badge.is-ok    { background: rgba(34,174,86,0.14);  color: #15803d; }
.farm-badge.is-fail  { background: rgba(220,38,38,0.12);  color: #b91c1c; }
.farm-badge.is-busy  { background: rgba(234,179,8,0.16);  color: #a16207; }
.farm-badge.is-none  { background: rgba(100,116,139,0.14); color: #475569; }

/* Dark theme */
html[data-theme='dark'] .farm-card {
    background: rgba(255,255,255,0.04);
    border-color: rgba(148,163,184,0.22);
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
html[data-theme='dark'] .farm-card:hover { border-color: var(--color-primary); }
html[data-theme='dark'] .farm-card-thumb { background: rgba(255,255,255,0.05); }
html[data-theme='dark'] .farm-card-title { color: #e2e8f0; }
html[data-theme='dark'] .farm-card-value { color: #cbd5e1; }
html[data-theme='dark'] .farm-badge.is-ok    { background: rgba(34,174,86,0.22);  color: #4ade80; }
html[data-theme='dark'] .farm-badge.is-fail  { background: rgba(220,38,38,0.22);  color: #fca5a5; }
html[data-theme='dark'] .farm-badge.is-busy  { background: rgba(234,179,8,0.22);  color: #fde047; }
html[data-theme='dark'] .farm-badge.is-none  { background: rgba(148,163,184,0.20); color: #cbd5e1; }

/* === Hero quick-action categories (returning users) ====================== */
.hero-categories {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-top: 1.25rem;
    width: min(600px, 92vw);
}
.hero-category-btn {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1rem;
    background: #fff;
    border: 1px solid rgba(2,6,23,0.08);
    border-radius: 0.75rem;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    color: #334155;
    transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
    text-align: left;
}
.hero-category-btn:hover {
    background: #f8fafc;
    border-color: rgba(0,162,197,0.3);
    box-shadow: 0 2px 8px rgba(0,162,197,0.08);
    transform: translateY(-1px);
}
.hero-category-btn:active { transform: translateY(0); }
.hero-category-btn:disabled { opacity: 0.55; cursor: default; box-shadow: none; transform: none; }
.hero-category-btn .category-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 0.5rem;
    background: rgba(0,162,197,0.08);
    color: var(--color-primary);
    flex-shrink: 0;
}
@media (max-width: 600px) {
    .hero-categories { grid-template-columns: 1fr; gap: 0.5rem; }
    .hero-category-btn { font-size: 0.8rem; padding: 0.6rem 0.85rem; }
}
html[data-theme='dark'] .hero-category-btn {
    background: rgba(30,41,59,0.5);
    border-color: rgba(148,163,184,0.14);
    color: #cbd5e1;
}
html[data-theme='dark'] .hero-category-btn:hover {
    background: rgba(30,41,59,0.75);
    border-color: rgba(0,162,197,0.35);
}
html[data-theme='dark'] .hero-category-btn .category-icon {
    background: rgba(0,162,197,0.12);
    color: #69d9f0;
}
html[data-theme='dark'] .post-setup-grid .onboarding-option-icon {
    background: rgba(0,162,197,0.12);
    color: #69d9f0;
}

/* Loading skeletons for the hero quick-actions (shown while /quick-actions loads) */
.hero-category-skeleton {
    pointer-events: none;
    cursor: default;
    transform: none !important;
    box-shadow: none;
}
.hero-category-skeleton .skeleton-block,
.hero-category-skeleton .skeleton-line {
    background: linear-gradient(90deg, rgba(2,6,23,0.06) 25%, rgba(2,6,23,0.12) 37%, rgba(2,6,23,0.06) 63%);
    background-size: 400% 100%;
    animation: heroSkeletonShimmer 1.4s ease infinite;
    border-radius: 0.4rem;
}
.hero-category-skeleton .skeleton-line {
    height: 0.7rem;
    flex: 1;
    max-width: 60%;
}
@keyframes heroSkeletonShimmer {
    0% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}
@media (prefers-reduced-motion: reduce) {
    .hero-category-skeleton .skeleton-block,
    .hero-category-skeleton .skeleton-line { animation: none; }
}
html[data-theme='dark'] .hero-category-skeleton .skeleton-block,
html[data-theme='dark'] .hero-category-skeleton .skeleton-line {
    background: linear-gradient(90deg, rgba(148,163,184,0.10) 25%, rgba(148,163,184,0.20) 37%, rgba(148,163,184,0.10) 63%);
    background-size: 400% 100%;
}

/* === Related questions (chips under bot messages) ========================= */
.related-questions-container {
    margin-top: 0.9rem;
    padding-top: 0.75rem;
    border-top: 1px dashed rgba(var(--color-primary-rgb), 0.25);
}
.related-questions-title {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--color-muted);
    margin-bottom: 0.55rem;
}
.related-questions-title svg { color: var(--color-primary); flex-shrink: 0; }
.related-questions-list {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.45rem;
}
.related-question-wrapper {
    display: inline-flex;
    align-items: stretch;
    gap: 0.25rem;
    max-width: 100%;
}
.related-question-btn {
    display: inline-flex;
    align-items: center;
    padding: 0.4rem 0.8rem;
    background: rgba(var(--color-primary-rgb), 0.06);
    border: 1px solid rgba(var(--color-primary-rgb), 0.3);
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 500;
    color: inherit;
    text-align: left;
    cursor: pointer;
    transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}
.related-question-btn:hover:not(:disabled) {
    background: rgba(var(--color-primary-rgb), 0.12);
    border-color: rgba(var(--color-primary-rgb), 0.55);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,162,197,0.15);
}
.related-question-btn:active:not(:disabled) { transform: translateY(0); }
.related-question-edit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    flex-shrink: 0;
    padding: 0;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 999px;
    color: var(--color-muted);
    cursor: pointer;
    opacity: 0;
    transition: opacity 140ms ease, background 140ms ease, color 140ms ease;
}
.related-question-wrapper:hover .related-question-edit-btn,
.related-question-edit-btn:focus-visible { opacity: 1; }
.related-question-edit-btn:hover:not(:disabled) {
    background: rgba(var(--color-primary-rgb), 0.1);
    color: var(--color-primary);
}
.related-question-btn:disabled {
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
    opacity: 0.55;
}
/* Edit affordance can't rely on hover on touch screens */
@media (hover: none) {
    .related-question-edit-btn { opacity: 1; }
}
html[data-theme='dark'] .related-question-btn {
    background: rgba(var(--color-primary-rgb), 0.1);
    color: #cbd5e1;
}
html[data-theme='dark'] .related-question-btn:hover:not(:disabled) {
    background: rgba(var(--color-primary-rgb), 0.18);
}

/* === First-time Orbit AI consent gate ==================================== */
.consent-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 1rem;
    -webkit-backdrop-filter: blur(10px) saturate(150%);
    backdrop-filter: blur(10px) saturate(150%);
}
.consent-modal-overlay.open { display: flex; }
.consent-modal-dialog {
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    background: var(--color-card, #fff);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 1.5rem;
}
/* Scrollable terms panel (consent.html injected here) */
.consent-terms-body {
    flex: 1 1 auto;
    min-height: 140px;
    overflow-y: auto;
    margin: 0.25rem 0 0.75rem;
    padding: 0.9rem 1rem;
    background: #fff;
    color: #3a4a54;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}
.consent-terms-body:focus-visible {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 0.14rem rgba(var(--color-primary-rgb), 0.2);
}
.consent-terms-loading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--color-muted);
    font-size: 0.85rem;
}
/* Terms are authored for a light surface — keep the panel light even in dark mode. */
html[data-theme='dark'] .consent-terms-body {
    background: #f8fafc;
    border-color: rgba(148,163,184,0.25);
}
.consent-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}
.consent-brand { display: inline-flex; align-items: center; gap: 0.6rem; }
.consent-brand-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(var(--color-primary-rgb), 0.1);
}
.consent-badge {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--color-primary);
    background: rgba(var(--color-primary-rgb), 0.1);
    border-radius: 999px;
    padding: 0.25rem 0.7rem;
}
.consent-close-btn {
    border: none;
    background: transparent;
    color: var(--color-muted);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.4rem;
    line-height: 0;
    display: inline-flex;
}
.consent-close-btn:hover { background: rgba(2,6,23,0.06); color: #0f172a; }
.consent-title { font-size: 1.4rem; font-weight: 600; color: #0f172a; margin: 0 0 0.75rem; }
.consent-lead { font-size: 0.9rem; color: #334155; margin: 0 0 0.75rem; }
.consent-text { font-size: 0.85rem; color: var(--color-muted); line-height: 1.55; margin: 0 0 0.75rem; }
.consent-check {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    margin: 1rem 0 0.5rem;
    font-size: 0.85rem;
    color: #334155;
    cursor: pointer;
}
.consent-check input {
    margin-top: 0.15rem;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: var(--color-primary);
}
.consent-check a,
.consent-terms-link { color: var(--color-primary); text-decoration: none; font-weight: 500; }
.consent-check a:hover,
.consent-terms-link:hover { text-decoration: underline; }
.consent-terms-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.82rem;
    margin-bottom: 1.25rem;
}
.consent-error { color: #dc2626; font-size: 0.8rem; margin-bottom: 0.75rem; }
.consent-actions { display: flex; justify-content: flex-end; gap: 0.6rem; }
.consent-actions .btn { min-width: 110px; }
.consent-actions .custom-primary-btn:disabled { opacity: 0.55; cursor: not-allowed; }
html[data-theme='dark'] .consent-modal-overlay { background: rgba(2,6,23,0.6); }
html[data-theme='dark'] .consent-modal-dialog { background: #0f172a; border-color: rgba(148,163,184,0.18); }
html[data-theme='dark'] .consent-title { color: #e2e8f0; }
html[data-theme='dark'] .consent-lead { color: #cbd5e1; }
html[data-theme='dark'] .consent-text { color: #94a3b8; }
html[data-theme='dark'] .consent-check { color: #cbd5e1; }
html[data-theme='dark'] .consent-close-btn:hover { background: rgba(255,255,255,0.08); color: #e2e8f0; }

/* ============================================================================
   LIQUID GLASS SURFACES
   Frosted, translucent material for floating UI — matches the input dock.
   Appended last so it overrides each surface's earlier background/shadow at
   equal specificity. Three tiers: menus/popovers (light frost), the sessions
   panel, and modals (denser frost so text stays crisp). Remove this block to
   revert every surface to its original solid style.
   ============================================================================ */

/* --- Tier 1: dropdown menus & popovers (light frost) --- */
.plus-menu,
.list-group-item .session-actions .session-menu,
.session-options-dropdown,
.settings-dropdown,
.map-search-results {
    /* Denser frost: these popovers are nested inside a backdrop-filter ancestor,
       so backdrop blur can't render — a high-opacity fill keeps them readable
       and frosted-looking instead of see-through. */
    -webkit-backdrop-filter: blur(24px) saturate(190%);
    backdrop-filter: blur(24px) saturate(190%);
    background: linear-gradient(180deg, rgba(255,255,255,0.92), rgba(238,246,249,0.88));
    border: 1px solid rgba(255,255,255,0.7);
    box-shadow:
        0 16px 40px -10px rgba(2,6,23,0.3),
        inset 0 1px 0 0 rgba(255,255,255,0.95);
}
html[data-theme='dark'] .plus-menu,
html[data-theme='dark'] .list-group-item .session-actions .session-menu,
html[data-theme='dark'] .session-options-dropdown,
html[data-theme='dark'] .settings-dropdown,
html[data-theme='dark'] .map-search-results {
    background: linear-gradient(180deg, rgba(30,41,59,0.92), rgba(15,23,42,0.88));
    border: 1px solid rgba(255,255,255,0.14);
    box-shadow:
        0 16px 40px -10px rgba(0,0,0,0.6),
        inset 0 1px 0 0 rgba(255,255,255,0.16);
}
/* Settings dropdown: a touch more frost than the other menus (light mode only;
   dark keeps the shared tier above via its higher specificity). */
.settings-dropdown {
    -webkit-backdrop-filter: blur(32px) saturate(200%);
    backdrop-filter: blur(32px) saturate(200%);
    background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(240,247,250,0.92));
}

/* --- Tier 2: sessions side panel ---
   The list items must be transparent, otherwise their solid Bootstrap-white
   cards cover the frost and the panel stops reading as glass. */
.sessions-overlay {
    -webkit-backdrop-filter: blur(22px) saturate(140%) brightness(1.35);
    backdrop-filter: blur(22px) saturate(140%) brightness(1.35);
    /* Bright glass over the dimmed backdrop: a strong brightness() lifts the
       darkened content behind so the panel glows brighter than its surroundings,
       while the white fill stays low enough to keep it translucent. */
    background: linear-gradient(180deg,
        rgba(255,255,255,0.4) 0%,
        rgba(255,255,255,0.32) 100%);
    border-right: 1px solid rgba(255,255,255,0.85);
    box-shadow:
        4px 0 40px rgba(2,6,23,0.12),
        inset 1px 1px 0 0 rgba(255,255,255,0.95);
}
.sessions-overlay .overlay-header {
    /* Transparent so the header matches the panel glass; an own fill would
       stack on the panel gradient and read as a brighter strip. */
    background: transparent;
    box-shadow: inset 0 -1px 0 rgba(2,6,23,0.06);
}
.sessions-overlay .list-group-item {
    background-color: transparent !important;
    box-shadow: none !important;
}
.sessions-overlay .list-group-item:not(.active):hover {
    background-color: rgba(255,255,255,0.5) !important;
}
.sessions-overlay .list-group-item.active {
    background-color: rgba(0,162,197,0.16) !important;
}
html[data-theme='dark'] .sessions-overlay {
    /* No brightness() here: the light-mode lift washes the panel grey over a
       dark chat, so dark mode keeps only the blur + saturation frost. */
    -webkit-backdrop-filter: blur(22px) saturate(140%);
    backdrop-filter: blur(22px) saturate(140%);
    background: linear-gradient(180deg,
        rgba(30,41,59,0.58) 0%,
        rgba(15,23,42,0.5) 100%);
    border-right: 1px solid rgba(255,255,255,0.12);
    box-shadow:
        4px 0 40px rgba(0,0,0,0.5),
        inset 1px 1px 0 0 rgba(255,255,255,0.14);
}
html[data-theme='dark'] .sessions-overlay .overlay-header {
    /* Transparent so the header matches the panel glass; an own fill would
       stack on the panel gradient and read as a lighter strip. */
    background: transparent;
    box-shadow: inset 0 -1px 0 rgba(255,255,255,0.08);
}
html[data-theme='dark'] .sessions-overlay .list-group-item:not(.active):hover {
    background-color: rgba(255,255,255,0.08) !important;
}
html[data-theme='dark'] .sessions-overlay .list-group-item.active {
    background-color: rgba(0,162,197,0.2) !important;
}

/* --- Tier 3: modals (denser frost for readability) --- */
.rename-modal-dialog,
.delete-modal-dialog,
.feedback-modal-dialog,
.consent-modal-dialog,
.map-modal-dialog {
    /* Same bright glass as the sessions panel, but a higher fill: a small
       centered modal needs more body than a large panel or it reads as barely
       there. */
    /* Bright white + transparent: the overlay behind is now a light frost, so
       a translucent white fill reads as clean bright white without needing an
       extreme brightness boost. */
    -webkit-backdrop-filter: blur(22px) saturate(150%) brightness(1.1);
    backdrop-filter: blur(22px) saturate(150%) brightness(1.1);
    background: linear-gradient(180deg, rgba(255,255,255,0.55), rgba(255,255,255,0.47));
    border: 1px solid rgba(255,255,255,0.9);
    box-shadow:
        0 30px 70px -18px rgba(2,6,23,0.3),
        inset 1px 1px 0 0 rgba(255,255,255,0.95);
}
html[data-theme='dark'] .rename-modal-dialog,
html[data-theme='dark'] .delete-modal-dialog,
html[data-theme='dark'] .feedback-modal-dialog,
html[data-theme='dark'] .consent-modal-dialog,
html[data-theme='dark'] .map-modal-dialog {
    background: linear-gradient(180deg, rgba(30,41,59,0.7), rgba(15,23,42,0.62));
    border: 1px solid rgba(255,255,255,0.12);
    box-shadow:
        0 30px 70px -18px rgba(0,0,0,0.6),
        inset 1px 1px 0 0 rgba(255,255,255,0.14);
}

/* --- Loading card: lighter glass, since it floats over the already-frosted
   blocking overlay (its own backdrop-filter can't render while nested). --- */
.interaction-blocking-overlay .loading-content {
    background: linear-gradient(180deg, rgba(255,255,255,0.42), rgba(255,255,255,0.34));
    border: 1px solid rgba(255,255,255,0.6);
    box-shadow:
        0 20px 50px -14px rgba(2,6,23,0.3),
        inset 0 1px 0 0 rgba(255,255,255,0.9);
}
html[data-theme='dark'] .interaction-blocking-overlay .loading-content {
    background: linear-gradient(180deg, rgba(30,41,59,0.42), rgba(15,23,42,0.34));
    border: 1px solid rgba(255,255,255,0.14);
    box-shadow:
        0 20px 50px -14px rgba(0,0,0,0.55),
        inset 0 1px 0 0 rgba(255,255,255,0.14);
}

/* --- Location badge: keep the teal tint, reframe as frosted glass --- */
.location-badge {
    -webkit-backdrop-filter: blur(18px) saturate(190%);
    backdrop-filter: blur(18px) saturate(190%);
    background: linear-gradient(135deg, rgba(0,162,197,0.34), rgba(34,174,86,0.3));
    border: 1px solid rgba(255,255,255,0.45);
    box-shadow:
        0 10px 24px -8px rgba(0,162,197,0.3),
        inset 0 1px 0 0 rgba(255,255,255,0.5);
}
html[data-theme='dark'] .location-badge {
    background: linear-gradient(135deg, rgba(0,162,197,0.24), rgba(34,174,86,0.2));
    border-color: rgba(0,162,197,0.3);
    box-shadow:
        0 14px 28px rgba(2,6,23,0.32),
        inset 0 1px 0 0 rgba(255,255,255,0.12);
}

/* --- Header action buttons: one matching chip for all four (history, new
   chat, download, settings) so they're consistent on the glass header. --- */
#history-btn,
#new-chat-btn,
#download-pdf-btn,
.settings-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0 !important;
    border-radius: 0.6rem;
    color: #334155;
    background: rgba(255,255,255,0.7);
    border: 1px solid rgba(2,6,23,0.1);
    box-shadow: 0 1px 3px rgba(2,6,23,0.06);
    transition: background 160ms ease, color 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}
#history-btn svg,
#new-chat-btn svg,
#download-pdf-btn svg,
.settings-toggle-btn svg {
    width: 18px;
    height: 18px;
    opacity: 1;
}
#history-btn:hover,
#new-chat-btn:hover,
#download-pdf-btn:hover,
.settings-toggle-btn:hover {
    background: rgba(255,255,255,0.92);
    border-color: rgba(2,6,23,0.18);
    color: #0f172a;
    box-shadow: 0 2px 8px rgba(2,6,23,0.1);
}
html[data-theme='dark'] #history-btn,
html[data-theme='dark'] #new-chat-btn,
html[data-theme='dark'] #download-pdf-btn,
html[data-theme='dark'] .settings-toggle-btn {
    color: #cbd5e1;
    background: rgba(255,255,255,0.06);
    border-color: rgba(148,163,184,0.2);
    box-shadow: none;
}
html[data-theme='dark'] #history-btn:hover,
html[data-theme='dark'] #new-chat-btn:hover,
html[data-theme='dark'] #download-pdf-btn:hover,
html[data-theme='dark'] .settings-toggle-btn:hover {
    background: rgba(255,255,255,0.12);
    border-color: rgba(148,163,184,0.35);
    color: #e5e7eb;
}