/* ==========================================================================
   Nexus Mail Assistant — taskpane styles (design "4a — simple chat").
   Every size, colour and spacing here mirrors the design file; colours come
   only from the brand x mode tokens below (set on <body> by applyTheme()).
   ========================================================================== */

/* --- Tokens: ESAB / ebxai x light / dark ---------------------------------- */
body, body[data-theme-brand="esab"][data-theme-mode="light"] {
    --ctx:#FFFFFF; --bg:#FFFFFF; --surface:#F5F5F5; --surface2:#EBEBEB; --ink:#1A1A1A; --ink2:#505050;
    --line:#DADADA; --line2:#8A8A8A; --acc:#FFE600; --accH:#EBD400; --onAcc:#000000; --accSoft:#FFF7A8; --accInk:#1A1A1A;
    --ok:#0B6A35; --okBg:#E4F3EA; --warn:#8A5300; --warnBg:#FFF1D6; --bad:#B3261E; --badBg:#FBEAE8; --info:#0B5CAD; --infoBg:#E6F0FB;
    --hover:#F0F0F0; --band:#141414; --onBand:#FFFFFF;
    color-scheme: light;
}
body[data-theme-brand="esab"][data-theme-mode="dark"] {
    --ctx:#292929; --bg:#1A1A1A; --surface:#313131; --surface2:#363636; --ink:#F2F2F2; --ink2:#C4C4C4;
    --line:#474747; --line2:#8F8F8F; --acc:#FFE600; --accH:#F0D800; --onAcc:#000000; --accSoft:#3A3610; --accInk:#FFE600;
    --ok:#7FD6A4; --okBg:#1C3527; --warn:#FFC46B; --warnBg:#3D2E12; --bad:#FF9F96; --badBg:#47201C; --info:#8CC2FF; --infoBg:#1A2D45;
    --hover:#3B3B3B; --band:#3F3F3F; --onBand:#FFFFFF;
    color-scheme: dark;
}
body[data-theme-brand="ebxai"][data-theme-mode="light"] {
    --ctx:#FFFFFF; --bg:#FFFFFF; --surface:#F3F4F6; --surface2:#E3EBEC; --ink:#16181D; --ink2:#4F555D;
    --line:#D9DDE1; --line2:#858B93; --acc:#1F7479; --accH:#185E62; --onAcc:#FFFFFF; --accSoft:#DFEDEE; --accInk:#1C6469;
    --ok:#0B6A35; --okBg:#E4F3EA; --warn:#8A5300; --warnBg:#FFF1D6; --bad:#B3261E; --badBg:#FBEAE8; --info:#0B5CAD; --infoBg:#E6F0FB;
    --hover:#EEF3F4; --band:#0C1C20; --onBand:#FFFFFF;
    color-scheme: light;
}
body[data-theme-brand="ebxai"][data-theme-mode="dark"] {
    --ctx:#102A2E; --bg:#051314; --surface:#153639; --surface2:#1A3035; --ink:#EAF2F2; --ink2:#B5C4C5;
    --line:#284A4F; --line2:#6E8C90; --acc:#1F7479; --accH:#24858B; --onAcc:#FFFFFF; --accSoft:#123236; --accInk:#5CC3C9;
    --ok:#7FD6A4; --okBg:#123326; --warn:#FFC46B; --warnBg:#3A2D10; --bad:#FF9F96; --badBg:#401E1B; --info:#8CC2FF; --infoBg:#13293D;
    --hover:#1C4146; --band:#1D484F; --onBand:#FFFFFF;
    color-scheme: dark;
}
/* Links produced by the markdown renderer (email-utils.js) reference this name. */
body { --accent-solid: var(--accInk); }

/* --- Base ------------------------------------------------------------------ */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
    background: var(--bg);
    color: var(--ink);
    font-family: "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    font-size: 14px;
    line-height: 20px;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}
button, textarea, select, input { font-family: inherit; }
button { margin: 0; }
button:focus-visible, select:focus-visible, textarea:focus-visible, input:focus-visible, a:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
}
textarea::placeholder, input::placeholder { color: var(--ink2); opacity: 1; }
[hidden] { display: none !important; }

@keyframes nxspin { to { transform: rotate(360deg); } }
@keyframes nxin { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes nxup { from { transform: translateY(32px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes nxfade { from { opacity: 0; } to { opacity: 1; } }

/* Material Symbols — every icon in the pane is a ligature of this font. */
.ms {
    font-family: 'Material Symbols Outlined';
    font-weight: normal;
    font-style: normal;
    font-size: 20px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-feature-settings: 'liga';
    font-feature-settings: 'liga';
    -webkit-font-smoothing: antialiased;
    flex: none;
    user-select: none;
}

.nx-spinner {
    width: 18px; height: 18px; flex: none;
    border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%;
    display: inline-block;
    animation: nxspin .8s linear infinite;
}

/* Shared small-caps section heading ("MY PROMPTS", "WHAT NEXT?", tool groups). */
.nx-caps {
    font-size: 12px; line-height: 16px; font-weight: 600; color: var(--ink2);
    text-transform: uppercase; letter-spacing: .04em;
}
.nx-muted { color: var(--ink2); }
.nx-small { font-size: 12px; line-height: 16px; color: var(--ink2); }
.nx-strong { font-weight: 600; }
.nx-ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nx-pretty { text-wrap: pretty; }

/* --- Frame ------------------------------------------------------------------ */
.nx {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg);
    color: var(--ink);
}

/* --- Header band -------------------------------------------------------------- */
.nx-head {
    height: 48px; flex: none;
    display: flex; align-items: center; gap: 8px;
    padding: 0 4px 0 14px;
    background: var(--band); color: var(--onBand);
}
.nx-logo {
    width: 24px; height: 24px; border-radius: 4px;
    background: var(--acc); color: var(--onAcc);
    display: grid; place-items: center;
    font-size: 13px; font-weight: 700; flex: none;
}
.nx-name { font-size: 16px; font-weight: 600; flex: 1; min-width: 0; }
.nx-dot {
    width: 8px; height: 8px; border-radius: 50%; flex: none; margin-right: 4px;
    background: transparent;
}
.nx-dot.is-connecting { border: 1.5px solid #8F8F8F; }
.nx-dot.is-online { background: #7FD6A4; }
.nx-dot.is-offline { background: #FF6B5E; }
.nx-dot.is-nokey { background: #FFC46B; }
.nx-hbtn {
    width: 36px; height: 36px; border: none; background: transparent; color: var(--onBand);
    border-radius: 4px; display: grid; place-items: center; cursor: pointer;
}
.nx-hbtn:hover, .nx-hbtn[aria-expanded="true"] { background: rgba(255,255,255,.12); }
.nx-hbtn .ms { font-size: 22px; }

/* --- Context bar -------------------------------------------------------------- */
.nx-ctx {
    flex: none; display: flex; align-items: center; gap: 8px;
    padding: 8px 6px 8px 12px; border-bottom: 1px solid var(--line); min-width: 0;
    background: var(--ctx);
}
.nx-ctx > .ms { color: var(--ink2); }
.nx-ctx-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.nx-ctx-label { font-size: 12px; line-height: 16px; color: var(--ink2); }
.nx-ctx-title { font-weight: 600; }

/* Generic 32px icon button (refresh, draft header, prompt edit …). */
.nx-ibtn {
    width: 32px; height: 32px; flex: none; border: none; border-radius: 4px;
    background: transparent; color: var(--ink);
    display: grid; place-items: center; cursor: pointer; padding: 0;
}
.nx-ibtn:hover { background: var(--hover); }
.nx-ibtn.is-on { background: var(--acc); color: var(--onAcc); }

/* --- Connection banner ---------------------------------------------------------- */
.nx-banner {
    flex: none; display: flex; gap: 10px; align-items: flex-start;
    padding: 12px; border-bottom: 1px solid var(--line);
}
.nx-banner.is-bad { background: var(--badBg); }
.nx-banner.is-warn { background: var(--warnBg); }
.nx-banner > .ms { font-size: 22px; line-height: 20px; }
.nx-banner.is-bad > .ms { color: var(--bad); }
.nx-banner.is-warn > .ms { color: var(--warn); }
.nx-banner-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.nx-col { display: flex; flex-direction: column; }
.nx-obtn {
    align-self: flex-start; height: 32px; padding: 0 12px;
    display: flex; align-items: center; gap: 6px;
    border: 1px solid var(--ink); border-radius: 4px; background: transparent; color: var(--ink);
    font-size: 14px; font-weight: 600; cursor: pointer;
}
.nx-obtn .ms { font-size: 18px; }

/* --- Phishing safety bar ------------------------------------------------------------ */
.nx-safety {
    flex: none; display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border: none; border-bottom: 1px solid var(--line);
    background: var(--surface); color: var(--ink);
    text-align: left; cursor: pointer; font-size: 14px; line-height: 20px; width: 100%;
}
.nx-safety.is-compact { padding: 4px 12px; min-height: 40px; }
.nx-safety.is-checking { background: var(--surface); color: var(--ink2); cursor: default; }
.nx-safety.tone-warn { background: var(--warnBg); }
.nx-safety.tone-bad { background: var(--badBg); }
.nx-safety.tone-info { background: var(--infoBg); }
.nx-safety-icon { font-size: 24px; }
.nx-safety.is-compact .nx-safety-icon { font-size: 20px; }
.nx-safety.tone-idle .nx-safety-icon { color: var(--ink2); }
/* Low risk stays neutral (no green "safe" signal) — see safetyView(). */
.nx-safety.tone-low .nx-safety-icon { color: var(--ink2); }
.nx-safety.tone-warn .nx-safety-icon { color: var(--warn); }
.nx-safety.tone-bad .nx-safety-icon { color: var(--bad); }
.nx-safety.tone-info .nx-safety-icon { color: var(--info); }
.nx-safety-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.nx-safety-sub { font-size: 12px; line-height: 16px; }
.nx-safety-pill {
    height: 32px; padding: 0 12px; display: flex; align-items: center;
    border: 1px solid var(--line2); border-radius: 4px; font-weight: 600; flex: none;
}

/* --- Scroll area ------------------------------------------------------------------- */
.nx-scroll { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; }

/* Thin, quiet scrollbars — the default ones are too heavy for a narrow task pane */
* { scrollbar-width: thin; scrollbar-color: var(--line2) transparent; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 3px; }
.nx-stream {
    flex: none; padding: 16px 12px 8px;
    display: grid; grid-template-columns: minmax(0, 1fr); grid-auto-rows: max-content; gap: 16px;
}

/* Start screen */
.nx-fresh { display: flex; flex-direction: column; gap: 14px; }
.nx-greet { display: flex; flex-direction: column; gap: 2px; }
.nx-greet-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.nx-greet-title { font-size: 16px; line-height: 22px; font-weight: 600; min-width: 0; }
.nx-seeall {
    flex: none; height: 28px; padding: 0 4px 0 10px; display: flex; align-items: center; gap: 2px;
    border: 1px solid var(--line2); border-radius: 14px; background: transparent; color: var(--ink);
    font-size: 12px; font-weight: 600; cursor: pointer;
}
.nx-seeall:hover { background: var(--hover); border-color: var(--ink2); }
.nx-seeall .ms { font-size: 16px; }
.nx-starters { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.nx-starter {
    min-height: 56px; display: flex; align-items: center; gap: 12px; padding: 8px 12px;
    border: none; border-bottom: 1px solid var(--line); background: var(--bg); color: var(--ink);
    text-align: left; cursor: pointer; font-size: 14px; line-height: 20px;
}
.nx-starter:hover { background: var(--hover); }
.nx-starter-icon {
    width: 36px; height: 36px; border-radius: 6px; background: var(--accSoft); color: var(--accInk);
    display: grid; place-items: center; flex: none;
}
.nx-starter > .ms { color: var(--ink2); }
.nx-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* My prompts */
.nx-prompts { display: flex; flex-direction: column; gap: 6px; }
.nx-chip {
    display: flex; align-items: center; gap: 2px;
    border: 1px solid var(--line2); border-radius: 20px; background: var(--bg);
    outline-offset: 2px;
}
.nx-chip.is-dragging { opacity: .4; }
.nx-chip.is-over { outline: 2px dashed var(--acc); }
.nx-chip-drag { font-size: 18px; color: var(--ink2); cursor: grab; padding-left: 4px; }
.nx-chip-run {
    flex: 1; min-width: 0; min-height: 40px; display: flex; align-items: center; gap: 10px; padding: 4px;
    border: none; background: transparent; color: var(--ink); font-size: 14px; text-align: left; cursor: pointer;
}
.nx-chip .nx-ibtn { color: var(--ink2); }
.nx-chip .nx-ibtn:hover { color: var(--ink); }
.nx-chip .nx-ibtn .ms { font-size: 18px; }
.nx-chip .nx-chip-del { border-radius: 50%; margin-right: 4px; }
.nx-chip .nx-chip-del:hover { background: var(--badBg); color: var(--bad); }
.nx-more {
    align-self: flex-start; min-height: 36px; display: flex; align-items: center; gap: 4px; padding: 0 4px;
    border: none; background: transparent; color: var(--ink); font-size: 14px; font-weight: 600; cursor: pointer;
}
.nx-add {
    min-height: 40px; display: flex; align-items: center; gap: 10px; padding: 4px 12px;
    border: 1px dashed var(--line2); border-radius: 20px; background: transparent; color: var(--ink);
    font-size: 14px; cursor: pointer; text-align: left;
}
.nx-add:hover { background: var(--hover); }

/* Messages */
.nx-sep { display: flex; align-items: center; gap: 8px; color: var(--ink2); font-size: 12px; line-height: 16px; min-width: 0; }
.nx-sep-line { flex: 1; min-width: 12px; height: 1px; background: var(--line); }
.nx-sep-mid { display: flex; align-items: center; gap: 4px; max-width: 85%; min-width: 0; }
/* Up to two lines, so the email subject is readable in a narrow pane (full text on hover). */
.nx-sep-text {
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
    overflow: hidden; overflow-wrap: anywhere; text-align: center;
}
.nx-sep-mid .ms { font-size: 16px; }
.nx-user {
    justify-self: end; max-width: 85%; padding: 8px 12px; background: var(--surface2);
    border-radius: 12px 12px 4px 12px; animation: nxin .2s ease-out; white-space: pre-line; overflow-wrap: anywhere;
}
.nx-err {
    display: flex; gap: 10px; align-items: flex-start; padding: 12px; border-radius: 8px;
    background: var(--badBg); animation: nxin .25s ease-out;
}
.nx-err > .ms { font-size: 22px; line-height: 20px; color: var(--bad); }
.nx-err-text { overflow-wrap: anywhere; }
.nx-ai { display: flex; flex-direction: column; gap: 4px; animation: nxin .25s ease-out; min-width: 0; }
.nx-ai-text { text-wrap: pretty; overflow-wrap: anywhere; }
.nx-ai-text p:last-child { margin-bottom: 0 !important; }
.nx-ai-text ul, .nx-ai-text ol { margin: 0; padding-left: 20px; }
.nx-langpick { display: flex; align-items: center; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.nx-langpick > .ms { font-size: 18px; color: var(--ink2); }
.nx-selwrap { position: relative; }
.nx-select {
    width: 100%; height: 36px; appearance: none; -webkit-appearance: none;
    border: 1px solid var(--line2); border-radius: 4px; background: var(--bg); color: var(--ink);
    font-size: 14px; padding: 0 30px 0 10px; cursor: pointer;
}
.nx-selwrap > .ms { position: absolute; right: 6px; top: 8px; pointer-events: none; }
.nx-select.is-sm { width: auto; height: 32px; padding: 0 28px 0 8px; }
.nx-selwrap.is-sm > .ms { right: 4px; top: 6px; }
.nx-result {
    display: flex; align-items: center; gap: 10px; padding: 8px 4px 8px 10px;
    border: 1px solid var(--line); border-radius: 6px; margin-top: 4px;
}
.nx-result > .ms { color: var(--ink2); }
.nx-result-btn {
    height: 32px; padding: 0 10px; flex: none; border: 1px solid var(--line2); border-radius: 4px;
    background: transparent; color: var(--ink); font-size: 14px; cursor: pointer;
}
.nx-result-btn:hover { background: var(--hover); }
.nx-result-btn:disabled { opacity: .6; cursor: default; }
.nx-actions { display: flex; gap: 2px; margin-left: -8px; flex-wrap: wrap; }
.nx-tbtn {
    height: 32px; padding: 0 8px; display: flex; align-items: center; gap: 6px;
    border: none; border-radius: 4px; background: transparent; color: var(--ink); font-size: 14px; cursor: pointer;
}
.nx-tbtn:hover { background: var(--hover); }
.nx-tbtn.is-on { background: var(--acc); color: var(--onAcc); }
.nx-tbtn .ms { font-size: 18px; }
.nx-loading { display: flex; align-items: center; gap: 8px; color: var(--ink2); }

/* Draft card */
.nx-draft {
    border: 1px solid var(--line); border-radius: 6px; background: var(--bg);
    display: flex; flex-direction: column; animation: nxin .25s ease-out;
}
.nx-draft-head { display: flex; align-items: center; gap: 2px; padding: 4px 4px 4px 12px; border-bottom: 1px solid var(--line); }
.nx-draft-title { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; }
.nx-draft-subject { padding: 12px 12px 0; display: flex; flex-direction: column; gap: 4px; }
.nx-draft-body { padding: 12px; }
.nx-draft-foot { padding: 0 12px 12px; }
.nx-input {
    height: 36px; width: 100%; border: 1px solid var(--line2); border-radius: 4px;
    background: var(--bg); color: var(--ink); font-size: 14px; padding: 0 10px; outline: none;
}
.nx-textarea {
    width: 100%; border: 1px solid var(--line2); border-radius: 4px; background: var(--bg); color: var(--ink);
    font-size: 14px; line-height: 20px; padding: 8px 10px; resize: none; outline: none; display: block;
}
/* The draft grows with its text, so the chat is the only scroll area (no scroll-in-scroll) */
.nx-textarea.is-draft { border-color: var(--line); background: var(--surface); padding: 10px; resize: vertical; field-sizing: content; min-height: 120px; overflow-y: auto; }
.nx-textarea.is-resizable { resize: vertical; }
.nx-input:focus, .nx-textarea:focus { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); outline: none; }
.nx-inkbtn {
    height: 40px; width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px;
    border: none; border-radius: 4px; background: var(--ink); color: var(--bg); font-size: 14px; font-weight: 600; cursor: pointer;
}
/* In dark mode an ink button would be a light block with dark text — use the
   accent instead so button text stays light (ESAB keeps black on yellow). */
body[data-theme-mode="dark"] .nx-inkbtn { background: var(--acc); color: var(--onAcc); }
body[data-theme-mode="dark"] .nx-inkbtn:hover { background: var(--accH); }

/* --- Composer ------------------------------------------------------------------------ */
.nx-composer {
    position: sticky; bottom: 0; margin-top: auto; flex: none;
    padding: 10px 12px 12px; background: var(--surface); border-top: 1px solid var(--line);
    box-shadow: 0 -4px 12px rgba(0,0,0,.06);
    display: flex; flex-direction: column; gap: 8px;
}
.nx-stopbar {
    align-self: center; height: 30px; display: flex; align-items: center; gap: 6px; padding: 0 14px;
    border: 1px solid var(--line2); border-radius: 15px; background: var(--bg); color: var(--ink);
    font-size: 13px; font-weight: 600; cursor: pointer; animation: nxin .2s ease-out;
}
.nx-stopbar:hover { background: var(--hover); }
.nx-stopbar .ms { font-size: 18px; }
.nx-next { display: flex; flex-direction: column; gap: 6px; }
.nx-next-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; container-type: inline-size; }
.nx-next-actions { display: flex; align-items: center; gap: 2px; margin-right: -6px; }
/* Narrow pane: "All tools" and "Start over" become icon-only (tooltip has the text). */
@container (max-width: 340px) {
    .nx-home-label { display: none; }
    .nx-home { padding: 0 6px; }
    .nx-home .ms { font-size: 18px; }
}
.nx-home {
    height: 28px; padding: 0 6px; display: flex; align-items: center; gap: 4px;
    border: none; border-radius: 4px; background: transparent; color: var(--ink);
    font-size: 12px; font-weight: 600; cursor: pointer;
}
/* --hover is nearly the same shade as --surface (the composer band), so transparent
   buttons sitting on that band use an ink tint instead — visible in every theme. */
.nx-home:hover, .nx-langbtn:hover { background: color-mix(in srgb, var(--ink) 10%, transparent); }
.nx-home .ms { font-size: 16px; }
.nx-next-wrap { position: relative; }
.nx-next-row {
    display: flex; gap: 6px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
    margin: 0 -12px; padding: 0 12px;
}
.nx-next-row::-webkit-scrollbar { display: none; }
.nx-nchip {
    flex: none; height: 32px; display: flex; align-items: center; gap: 6px; padding: 0 12px;
    border: 1px solid var(--line2); border-radius: 16px; background: var(--bg); color: var(--ink);
    font-size: 14px; cursor: pointer; white-space: nowrap;
}
.nx-nchip:hover { background: var(--hover); }
.nx-nchip .ms { font-size: 16px; }
.nx-fade {
    box-sizing: content-box;
    position: absolute; top: 0; bottom: 0; width: 52px; display: flex; align-items: center; padding: 0 6px;
    pointer-events: none;
}
.nx-fade.is-left { left: -12px; justify-content: flex-start; background: linear-gradient(to right, var(--surface) 55%, transparent); }
.nx-fade.is-right { right: -12px; justify-content: flex-end; background: linear-gradient(to left, var(--surface) 55%, transparent); }
.nx-fade button {
    pointer-events: auto; width: 28px; height: 28px; border: 1px solid var(--line2); border-radius: 50%;
    background: var(--bg); color: var(--ink); display: grid; place-items: center; cursor: pointer; padding: 0;
}
.nx-fade button:hover { background: var(--hover); }
.nx-fade .ms { font-size: 18px; }
.nx-box {
    position: relative;
    border: 1px solid var(--line2); border-radius: 8px; background: var(--bg);
    display: flex; align-items: flex-end; gap: 4px; padding: 4px;
}
.nx-sq {
    width: 36px; height: 36px; flex: none; border: none; border-radius: 6px;
    background: transparent; color: var(--ink); display: grid; place-items: center; cursor: pointer; padding: 0;
}
.nx-sq:hover { background: var(--hover); }
.nx-sq .ms { font-size: 22px; }
.nx-send { background: var(--surface2); color: var(--ink2); }
.nx-send:hover { background: var(--surface2); }
.nx-send.is-ready, .nx-send.is-ready:hover { background: var(--acc); color: var(--onAcc); }
.nx-send .ms { font-size: 20px; }
.nx-chatinput {
    flex: 1; min-width: 0; min-height: 36px; max-height: 120px; border: none; outline: none; resize: none;
    background: transparent; color: var(--ink); font-size: 14px; line-height: 20px; padding: 8px 2px;
    field-sizing: content; overflow-y: auto;
    box-sizing: content-box; /* as in the design: 36px of text area + 16px padding */
}
/* Drag handle on the top edge of the message box: drag up = taller box. */
.nx-grip {
    position: absolute; top: -7px; left: 50%; transform: translateX(-50%);
    width: 64px; height: 14px; display: flex; align-items: center; justify-content: center;
    cursor: ns-resize; touch-action: none; z-index: 1; border-radius: 7px;
}
.nx-grip::before { content: ""; width: 36px; height: 4px; border-radius: 2px; background: var(--line2); opacity: .55; transition: opacity .15s; }
.nx-grip:hover::before, .nx-grip:focus-visible::before, .nx-grip.is-dragging::before { opacity: 1; }
.nx-chatinput:focus, .nx-chatinput:focus-visible { outline: none; box-shadow: none; }
.nx-foot {
    display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
    font-size: 12px; line-height: 16px; color: var(--ink2); padding: 0 2px;
}
.nx-answers { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.nx-anchor { position: relative; display: inline-flex; }
.nx-langbtn {
    height: 28px; display: flex; align-items: center; gap: 2px; padding: 0 4px;
    border: none; border-radius: 4px; background: transparent; color: var(--ink);
    font-size: 12px; font-weight: 600; cursor: pointer;
}
.nx-langbtn .nx-u { text-decoration: underline; text-underline-offset: 3px; }
.nx-langbtn .ms { font-size: 16px; }
.nx-scrim { position: fixed; inset: 0; z-index: 29; }
.nx-listbox {
    box-sizing: content-box;
    position: absolute; right: 0; bottom: calc(100% + 4px); z-index: 30; width: 200px;
    max-height: min(280px, 60vh); overflow-y: auto; padding: 4px;
    border: 1px solid var(--line2); border-radius: 8px; background: var(--bg);
    box-shadow: 0 8px 24px rgba(0,0,0,.18); display: flex; flex-direction: column;
}
.nx-option {
    min-height: 36px; display: flex; align-items: center; gap: 8px; padding: 0 10px;
    border: none; border-radius: 4px; background: transparent; color: var(--ink);
    font-size: 14px; font-weight: 400; text-align: left; cursor: pointer; flex: none;
}
.nx-option:hover { background: var(--hover); }
.nx-option.is-on { background: var(--accSoft); font-weight: 600; }
.nx-option .ms { font-size: 18px; color: var(--accInk); }

/* --- Settings view ------------------------------------------------------------------------ */
.nx-settings-scroll { flex: 1; min-height: 0; overflow-y: auto; }
.nx-settings { display: flex; flex-direction: column; gap: 22px; padding: 8px 16px 20px; }
.nx-settings-top { display: flex; align-items: center; gap: 6px; margin-left: -8px; }
.nx-settings-title { flex: 1; font-size: 16px; font-weight: 600; }
.nx-saved { display: flex; align-items: center; gap: 4px; font-size: 12px; line-height: 16px; color: var(--ink2); white-space: nowrap; }
.nx-saved .ms { font-size: 16px; color: var(--ok); }
.nx-field { display: flex; flex-direction: column; gap: 6px; }
.nx-label { font-size: 14px; font-weight: 600; }
.nx-seg {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px; padding: 2px;
    background: var(--surface2); border-radius: 6px;
}
.nx-seg.is-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.nx-seg button {
    height: 32px; border: none; border-radius: 4px; background: transparent; color: var(--ink);
    font-size: 14px; font-weight: 400; cursor: pointer;
}
.nx-seg button.is-on { background: var(--acc); color: var(--onAcc); font-weight: 600; }
.nx-switch {
    min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
    border: none; border-bottom: 1px solid var(--line); background: transparent; color: var(--ink);
    font-size: 14px; padding: 10px 0; cursor: pointer; text-align: left; width: 100%;
}
.nx-track {
    width: 40px; height: 20px; border-radius: 10px; position: relative; flex: none;
    background: transparent; border: 1px solid var(--line2); transition: background .15s;
}
.nx-knob {
    position: absolute; top: 3px; left: 3px; width: 12px; height: 12px; border-radius: 50%;
    background: var(--ink2); transition: left .15s;
}
.nx-switch[aria-checked="true"] .nx-track { background: var(--acc); border-color: var(--acc); }
.nx-switch[aria-checked="true"] .nx-knob { left: 23px; background: var(--onAcc); }
.nx-conn { display: flex; flex-direction: column; gap: 12px; }
.nx-connline { display: flex; align-items: center; gap: 8px; }
.nx-connline .nx-dot { margin-right: 0; background: var(--ok); }
.nx-connline .nx-dot.is-offline { background: var(--bad); }
.nx-connline .nx-dot.is-nokey { background: var(--warn); }
.nx-connline .nx-dot.is-connecting { background: transparent; }
.nx-lock { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; line-height: 16px; color: var(--ink2); }
.nx-lock .ms { font-size: 16px; line-height: 16px; }
.nx-labelrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.nx-labelrow a { font-size: 12px; color: var(--ink); text-decoration: underline; }
.nx-keyrow { display: flex; gap: 6px; }
.nx-keyrow .nx-input { flex: 1; min-width: 0; }
.nx-keyrow .nx-input.is-masked { -webkit-text-security: disc; }
.nx-eye {
    width: 36px; height: 36px; flex: none; border: 1px solid var(--line2); border-radius: 4px;
    background: transparent; color: var(--ink); display: grid; place-items: center; cursor: pointer; padding: 0;
}
.nx-about {
    border-top: 1px solid var(--line); padding-top: 12px; display: flex; justify-content: space-between;
    gap: 8px; flex-wrap: wrap; font-size: 12px; line-height: 16px; color: var(--ink2);
}

/* --- Bottom sheet ---------------------------------------------------------------------- */
.nx-overlay { position: absolute; inset: 48px 0 0 0; background: rgba(0,0,0,.4); z-index: 10; animation: nxfade .15s ease-out; }
.nx-sheet {
    position: absolute; left: 0; right: 0; bottom: 0; max-height: calc(100% - 72px); z-index: 11;
    background: var(--bg); border-radius: 12px 12px 0 0; display: flex; flex-direction: column;
    box-shadow: 0 -6px 24px rgba(0,0,0,.25); animation: nxup .22s ease-out;
}
.nx-overlay.is-static, .nx-sheet.is-static { animation: none; }
.nx-sheet-head { flex: none; display: flex; align-items: center; gap: 6px; padding: 10px 6px 6px 16px; }
.nx-sheet-back { margin-left: -10px; }
.nx-sheet-title { flex: 1; font-size: 16px; line-height: 22px; font-weight: 600; }
.nx-sheet-close {
    width: 36px; height: 36px; border: none; background: transparent; color: var(--ink); border-radius: 4px;
    display: grid; place-items: center; cursor: pointer; padding: 0;
}
.nx-sheet-close:hover { background: var(--hover); }
.nx-sheet-close .ms { font-size: 22px; }
.nx-sheet-body {
    flex: 1; min-height: 0; overflow-y: auto; padding: 4px 16px 16px;
    display: grid; grid-template-columns: minmax(0, 1fr); grid-auto-rows: max-content; gap: 14px;
}
.nx-bleed { display: flex; flex-direction: column; margin: 0 -16px; }
.nx-menuitem {
    min-height: 48px; display: flex; align-items: center; gap: 14px; padding: 0 16px;
    border: none; background: transparent; color: var(--ink); font-size: 14px; text-align: left; cursor: pointer;
}
.nx-menuitem:hover { background: var(--hover); }
.nx-menuitem .ms { font-size: 22px; }
.nx-group { display: flex; flex-direction: column; gap: 4px; }
.nx-tool {
    min-height: 52px; display: flex; align-items: center; gap: 14px; padding: 4px 16px;
    border: none; background: transparent; color: var(--ink); text-align: left; cursor: pointer;
    font-size: 14px; line-height: 20px;
}
.nx-tool:hover { background: var(--hover); }
.nx-tool-icon { font-size: 22px; color: var(--accInk); width: 24px; text-align: center; }
.nx-tool-icon.is-prompt { font-size: 20px; color: var(--ink2); }
.nx-outline-btn {
    height: 40px; display: flex; align-items: center; justify-content: center; gap: 8px;
    border: 1px solid var(--line2); border-radius: 4px; background: transparent; color: var(--ink);
    font-size: 14px; font-weight: 600; cursor: pointer;
}
.nx-intents { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.nx-intent {
    height: 44px; display: flex; align-items: center; gap: 8px; padding: 0 10px; border-radius: 4px;
    border: 1px solid var(--line2); background: transparent; color: var(--ink); font-size: 14px; font-weight: 400;
    cursor: pointer; min-width: 0; text-align: left;
}
.nx-intent.is-on { border: 2px solid var(--acc); background: var(--accSoft); font-weight: 600; }
.nx-intent .ms { font-size: 18px; }
.nx-linkbtn {
    height: 32px; padding: 0 6px; display: flex; align-items: center; gap: 6px;
    border: none; border-radius: 4px; background: transparent; color: var(--ink);
    font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}
.nx-linkbtn .ms { font-size: 18px; }
.nx-formfoot { border-top: 1px solid var(--line); padding-top: 6px; display: flex; flex-direction: column; gap: 10px; }
.nx-opts {
    min-height: 40px; display: flex; align-items: center; gap: 8px; border: none; background: transparent;
    color: var(--ink); padding: 0; text-align: left; cursor: pointer; font-size: 14px; line-height: 20px;
}
.nx-opts-link { font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.nx-optgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.nx-optgrid .nx-field { min-width: 0; }
.nx-primary {
    height: 44px; width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px;
    border: none; border-radius: 4px; background: var(--acc); color: var(--onAcc);
    font-size: 14px; font-weight: 600; cursor: pointer;
}
.nx-primary:hover { background: var(--accH); }
.nx-btnrow { display: flex; gap: 8px; }
.nx-btnrow .nx-primary { flex: 1; width: auto; }
.nx-danger {
    height: 44px; padding: 0 14px; display: flex; align-items: center; gap: 6px;
    border: 1px solid var(--line2); border-radius: 4px; background: transparent; color: var(--bad);
    font-size: 14px; font-weight: 600; cursor: pointer;
}

/* Phishing details (inside the sheet) */
.nx-phish { display: flex; flex-direction: column; gap: 14px; }
.nx-simbox { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border-radius: 6px; background: var(--infoBg); }
.nx-simbox > .ms { font-size: 22px; line-height: 20px; color: var(--info); }
.nx-score { display: flex; flex-direction: column; gap: 8px; }
.nx-score-row { display: flex; align-items: baseline; gap: 6px; }
.nx-score-num { font-size: 32px; line-height: 36px; font-weight: 700; }
.nx-badge { margin-left: auto; padding: 2px 10px; border-radius: 12px; font-size: 12px; line-height: 20px; font-weight: 600; align-self: center; }
.nx-bar { height: 6px; border-radius: 3px; background: var(--surface2); overflow: hidden; }
.nx-bar > div { width: 0; height: 100%; border-radius: 3px; transition: width .8s ease; }
.lv-low .nx-score-num { color: var(--ink); }
.lv-low .nx-reason .ms { color: var(--ink2); }
.lv-medium .nx-score-num, .lv-medium .nx-reason .ms { color: var(--warn); }
.lv-high .nx-score-num, .lv-high .nx-reason .ms { color: var(--bad); }
.lv-low .nx-badge { background: var(--surface2); color: var(--ink); }
.lv-medium .nx-badge { background: var(--warnBg); color: var(--warn); }
.lv-high .nx-badge { background: var(--badBg); color: var(--bad); }
.lv-low .nx-bar > div { background: var(--ink2); }
.lv-medium .nx-bar > div { background: var(--warn); }
.lv-high .nx-bar > div { background: var(--bad); }
.nx-reason { display: flex; gap: 8px; align-items: flex-start; }
.nx-reason .ms { font-size: 18px; line-height: 20px; }
.nx-note {
    display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: 6px;
    background: var(--surface); font-size: 12px; line-height: 16px; color: var(--ink2);
}
.nx-note .ms { font-size: 16px; line-height: 16px; }

/* --- Toast ------------------------------------------------------------------------------ */
.nx-toast {
    /* Sits over the 48px header band, so it never hides the email context or a sheet title */
    position: absolute; left: 8px; right: 8px; top: 4px; min-height: 40px; z-index: 20;
    display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 6px;
    background: var(--ink); color: var(--bg); font-size: 14px; box-shadow: 0 4px 16px rgba(0,0,0,.25);
    animation: nxin .2s ease-out; cursor: pointer;
}
.nx-toast .ms { font-size: 18px; }
/* Short confirmations let clicks through to the header buttons below them;
   errors stay clickable so they can be dismissed early. */
.nx-toast:not(.is-error) { pointer-events: none; }

/* --- Loading screen (static markup in taskpane.html until the UI is built) --- */
.nx-boot {
    height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
    color: var(--ink2); animation: nxfade .3s ease-out;
}
.nx-boot .nx-logo { width: 40px; height: 40px; border-radius: 8px; font-size: 20px; }
/* The pane didn't finish starting (js/boot-watchdog.js). */
.nx-boot.is-failed { padding: 0 24px; text-align: center; gap: 12px; }
.nx-boot-title { font-size: 16px; line-height: 22px; font-weight: 600; color: var(--ink); }
.nx-boot-text { max-width: 320px; font-size: 14px; line-height: 20px; }
.nx-boot .nx-primary { width: auto; padding: 0 24px; margin-top: 4px; }

/* Re-rendered chat messages (see renderMessages) keep still instead of fading in again.
   Last in the file so it overrides every message type's own animation. */
.is-redraw, .is-redraw * { animation: none; }

/* Expanded Outlook pane ("Rozwiń okienko aplikacji", ~770px at 1920px): the width is set by
   Outlook, so keep the content at a readable 600px, centred; bars and background stay full width. */
@media (min-width: 640px) {
    .nx-ctx, .nx-banner, .nx-safety, .nx-stream, .nx-composer, .nx-settings {
        padding-left: calc((100% - 600px) / 2); padding-right: calc((100% - 600px) / 2);
    }
    .nx-sheet { max-width: 640px; margin: 0 auto; }
}
