/* Help desk: the support page, tickets, the staff help desk, the live chat widget and the agent console.
   Uses the tokens from site.css (colours, radii, fonts). */

/* ---------- Shared bits ---------- */
.back-link { display: inline-flex; align-items: center; gap: 0.4rem; margin-bottom: 14px; color: var(--muted); font-size: 0.86rem; font-weight: 600; text-decoration: none; }
.back-link:hover { color: var(--gold); }
.link-button { padding: 0; border: 0; background: none; color: var(--gold); font: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.presence-dot { display: inline-block; flex: none; width: 9px; height: 9px; border-radius: 50%; background: #6b6290; box-shadow: 0 0 0 3px rgba(107, 98, 144, 0.22); }
.presence-dot.on { background: var(--good-text); box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.22); animation: presence-pulse 2.4s ease-in-out infinite; }
@keyframes presence-pulse { 50% { box-shadow: 0 0 0 6px rgba(74, 222, 128, 0.06); } }
.facts { display: grid; gap: 10px; margin: 0 0 16px; }
.facts > div { display: grid; gap: 2px; }
.facts dt { color: var(--muted); font-size: 0.74rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.facts dd { margin: 0; color: var(--ink); font-size: 0.9rem; overflow-wrap: anywhere; }

/* ---------- Support home ---------- */
.help-hero {
    display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 24px; align-items: center;
    margin-bottom: 24px; padding: clamp(20px, 3vw, 32px); border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
    background: radial-gradient(circle at 0 0, rgba(155, 107, 255, 0.28), transparent 55%), radial-gradient(circle at 100% 100%, rgba(255, 201, 77, 0.14), transparent 50%), var(--surface);
}
.help-hero h1 { margin: 6px 0 8px; font-size: clamp(1.7rem, 3.4vw, 2.3rem); }
.help-hero p { margin: 0; color: var(--ink-2); max-width: 52ch; }
.help-options { display: grid; gap: 12px; }
.help-option {
    display: flex; align-items: center; gap: 14px; width: 100%; padding: 16px 18px;
    border: 1px solid var(--border-strong); border-radius: var(--radius); background: rgba(12, 7, 25, 0.55);
    color: var(--ink); font: inherit; text-align: left; text-decoration: none; cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.help-option:hover, .help-option:focus-visible { transform: translateY(-2px); border-color: var(--gold); background: rgba(255, 201, 77, 0.07); color: var(--ink); }
.help-option-icon { display: grid; place-items: center; flex: none; width: 46px; height: 46px; border-radius: 14px; font-size: 1.35rem; }
.help-option.chat .help-option-icon { background: rgba(74, 222, 128, 0.14); color: var(--good-text); }
.help-option.ticket .help-option-icon { background: var(--gold-soft); color: var(--gold); }
.help-option-text { display: grid; gap: 3px; flex: 1; min-width: 0; }
.help-option-text strong { font: 600 1.05rem var(--font-brand); }
.help-option-text small { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.84rem; }
.help-option-go { color: var(--muted); }

.ticket-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.ticket-row {
    display: flex; align-items: center; gap: 14px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.02); color: var(--ink); text-decoration: none; transition: border-color 0.15s ease, background 0.15s ease;
}
.ticket-row:hover { border-color: var(--border-strong); background: var(--raised); color: var(--ink); }
.ticket-row.unread { border-color: rgba(74, 222, 128, 0.4); background: rgba(22, 163, 74, 0.07); }
.ticket-icon { display: grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 12px; background: var(--raised-2); color: var(--gold); }
.ticket-main { display: grid; gap: 2px; flex: 1; min-width: 0; }
.ticket-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket-main small { color: var(--muted); font-size: 0.8rem; }
.ticket-side { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }

.help-links { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.help-links a { display: flex; gap: 12px; padding: 10px; border-radius: var(--radius-sm); color: var(--ink); text-decoration: none; }
.help-links a:hover { background: var(--raised); color: var(--ink); }
.help-links i { color: var(--gold); font-size: 1.1rem; line-height: 1.4; }
.help-links span { display: grid; gap: 2px; }
.help-links strong { font-size: 0.9rem; }
.help-links small { color: var(--muted); font-size: 0.8rem; }

/* ---------- New ticket ---------- */
fieldset.field { margin: 0; padding: 0; border: 0; min-width: 0; }
fieldset.field legend { float: left; width: 100%; margin-bottom: 8px; color: var(--ink-2); font-size: 0.85rem; font-weight: 600; text-shadow: none; }
.category-grid { clear: both; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); }
.category-choice { position: relative; display: block; cursor: pointer; }
.category-choice input { position: absolute; opacity: 0; pointer-events: none; }
.category-choice span {
    display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 10px 12px;
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: rgba(255, 255, 255, 0.02);
    color: var(--ink-2); font-size: 0.88rem; font-weight: 600; transition: border-color 0.15s ease, background 0.15s ease;
}
.category-choice span i { color: var(--muted); font-size: 1.05rem; }
.category-choice:hover span { border-color: var(--gold); }
.category-choice input:checked + span { border-color: var(--gold); background: var(--gold-soft); color: var(--ink); }
.category-choice input:checked + span i { color: var(--gold); }
.category-choice input:focus-visible + span { box-shadow: var(--focus); }

.attach-drop {
    display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 1px dashed var(--border-strong); border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.02); color: var(--ink-2); cursor: pointer; transition: border-color 0.15s ease, background 0.15s ease;
}
.attach-drop:hover, .attach-drop.dragging { border-color: var(--gold); background: var(--gold-soft); }
.attach-field:focus-within .attach-drop { box-shadow: var(--focus); }
.attach-drop > i { display: grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 12px; background: var(--raised-2); color: var(--gold); font-size: 1.1rem; }
.attach-drop span { display: grid; gap: 2px; }
.attach-drop strong { color: var(--ink); font-size: 0.9rem; }
.attach-drop small { color: var(--muted); font-size: 0.78rem; }
.attach-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.attach-list:empty { display: none; }
.attach-list li:not(.attach-clear) { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; padding: 6px 10px; border-radius: 999px; background: var(--raised); font-size: 0.82rem; }
.attach-list li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.attach-list li small { color: var(--muted); }
.attach-list li i { color: var(--gold); }

/* ---------- Ticket thread ---------- */
.ticket-header h1 { overflow-wrap: anywhere; }
.ticket-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--muted) !important; font-size: 0.86rem; }
.thread { display: grid; gap: 18px; margin: 0; padding: 0; list-style: none; }
.thread-message { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 12px; align-items: start; }
.thread-avatar {
    display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
    background: linear-gradient(135deg, var(--violet-strong), var(--magenta)); color: #fff; font-weight: 800;
}
.from-staff .thread-avatar { background: linear-gradient(135deg, var(--gold), var(--gold-strong)); color: var(--gold-ink); }
.thread-bubble { padding: 14px 16px; border: 1px solid var(--border); border-radius: 4px var(--radius) var(--radius) var(--radius); background: rgba(255, 255, 255, 0.03); }
.from-staff .thread-bubble { border-color: rgba(255, 201, 77, 0.22); background: rgba(255, 201, 77, 0.05); }
.thread-message.internal .thread-bubble { border-style: dashed; border-color: rgba(250, 178, 25, 0.45); background: repeating-linear-gradient(135deg, rgba(250, 178, 25, 0.05) 0 10px, transparent 10px 20px); }
.thread-bubble header { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 6px; }
.thread-bubble header time { margin-left: auto; color: var(--muted); font-size: 0.78rem; }
.thread-body { color: var(--ink-2); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; }
.thread-event { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; color: var(--muted); font-size: 0.82rem; text-align: center; }
.thread-event::before, .thread-event::after { content: ""; flex: 1 1 24px; height: 1px; background: var(--border); }
.thread-event time { opacity: 0.8; }
.thread-event.internal { color: var(--warning-text); }
.thread-files { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0 0; padding: 0; list-style: none; }
.file-thumb { display: block; width: 140px; height: 100px; overflow: hidden; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--page); }
.file-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.2s ease; }
.file-thumb:hover img { transform: scale(1.05); }
.file-chip { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); color: var(--ink); font-size: 0.84rem; text-decoration: none; }
.file-chip i { color: var(--critical-text); font-size: 1.1rem; }
.file-chip small { color: var(--muted); }
.file-chip:hover { border-color: var(--gold); color: var(--ink); }

.reply-panel { scroll-margin-top: 90px; }
.reply-mode { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 999px; background: var(--page-2); }
.reply-mode label { cursor: pointer; }
.reply-mode input { position: absolute; opacity: 0; pointer-events: none; }
.reply-mode span { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 999px; color: var(--muted); font-size: 0.84rem; font-weight: 700; }
.reply-mode input:checked + span { background: var(--raised-2); color: var(--ink); }
.reply-mode input:focus-visible + span { box-shadow: var(--focus); }
.reply-label-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.reply-label-row label { color: var(--ink-2); font-size: 0.85rem; font-weight: 600; }
select.canned { width: auto; max-width: 100%; min-height: 34px; padding: 4px 10px; font-size: 0.82rem; }
.is-note textarea { border-color: rgba(250, 178, 25, 0.55) !important; background: rgba(250, 178, 25, 0.05) !important; }

/* ---------- Staff help desk ---------- */
.desk-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.desk-tabs a {
    display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border: 1px solid var(--border); border-radius: 999px;
    color: var(--ink-2); font-size: 0.86rem; font-weight: 700; text-decoration: none;
}
.desk-tabs a:hover { border-color: var(--border-strong); color: var(--ink); }
.desk-tabs a[aria-current="page"] { border-color: var(--gold); background: var(--gold-soft); color: var(--ink); }
.desk-tabs .count, .console-tabs .count { padding: 0 0.45rem; border-radius: 999px; background: var(--raised-2); color: var(--ink-2); font-size: 0.72rem; font-weight: 800; }
.desk-tabs .count.hot, .console-tabs .count.hot, .console-item .count.hot { background: var(--critical); color: #fff; }
.desk-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 16px; }
.desk-filters select { width: auto; min-width: 180px; }
.desk-filters input[type="search"] { flex: 1 1 240px; width: auto; }
.desk-panel { padding: 8px; }
.desk-table td { vertical-align: top; }
.desk-subject { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); font-weight: 600; text-decoration: none; }
.desk-subject:hover { color: var(--gold); }
.desk-table tr.unread .desk-subject { font-weight: 800; }
.desk-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.desk-tags:empty { display: none; }
.unread-dot { display: inline-block; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--good-text); box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.2); }

/* ---------- Chat bubbles (widget and console) ---------- */
.chat-log { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.chat-msg { display: flex; }
.chat-msg.mine { justify-content: flex-end; }
.chat-bubble { position: relative; max-width: 82%; padding: 9px 12px 7px; border-radius: 16px 16px 16px 4px; background: var(--raised-2); color: var(--ink); }
.chat-msg.mine .chat-bubble { border-radius: 16px 16px 4px 16px; background: linear-gradient(135deg, var(--violet-strong), #9d4edd); }
.chat-bubble p { margin: 0; font-size: 0.9rem; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-name { display: block; margin-bottom: 2px; color: var(--gold); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.02em; }
.chat-msg.mine .chat-name { color: rgba(255, 255, 255, 0.75); }
.chat-bubble time { display: block; margin-top: 3px; color: rgba(251, 247, 255, 0.55); font-size: 0.68rem; text-align: right; }
.chat-msg.system { justify-content: center; }
.chat-msg.system p { max-width: 92%; margin: 4px 0; padding: 6px 12px; border-radius: 999px; background: rgba(255, 255, 255, 0.04); color: var(--muted); font-size: 0.78rem; text-align: center; }
.chat-typing { display: flex; align-items: center; gap: 8px; margin-top: 10px; color: var(--muted); font-size: 0.8rem; }
.chat-typing .dots { display: inline-flex; gap: 3px; padding: 8px 10px; border-radius: 12px; background: var(--raised-2); }
.chat-typing .dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-2); animation: typing-dot 1.2s infinite ease-in-out; }
.chat-typing .dots i:nth-child(2) { animation-delay: 0.15s; }
.chat-typing .dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing-dot { 0%, 60%, 100% { opacity: 0.35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* ---------- Player chat widget ---------- */
.chat-widget { position: fixed; right: 22px; bottom: 22px; z-index: 60; }
.chat-launcher {
    position: relative; display: inline-flex; align-items: center; gap: 8px; height: 56px; padding: 0 20px 0 18px;
    border: 0; border-radius: 999px; background: linear-gradient(135deg, var(--gold), var(--gold-strong)); color: var(--gold-ink);
    font: 800 0.95rem var(--font-ui); box-shadow: 0 14px 34px rgba(245, 165, 36, 0.35), 0 4px 10px rgba(5, 2, 14, 0.5);
    cursor: pointer; transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.chat-launcher:hover { transform: translateY(-2px); box-shadow: 0 18px 40px rgba(245, 165, 36, 0.45), 0 4px 10px rgba(5, 2, 14, 0.5); }
.chat-launcher:focus-visible { outline: none; box-shadow: var(--focus), 0 14px 34px rgba(245, 165, 36, 0.35); }
.chat-launcher i { font-size: 1.35rem; }
.chat-launcher.has-unread { animation: launcher-bounce 2.8s ease-in-out infinite; }
@keyframes launcher-bounce { 0%, 88%, 100% { transform: translateY(0); } 92% { transform: translateY(-6px); } 96% { transform: translateY(0); } }
.chat-badge {
    position: absolute; top: -4px; right: -4px; display: grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px;
    border: 2px solid var(--page); border-radius: 999px; background: var(--critical); color: #fff; font-size: 0.72rem; font-weight: 800;
}
.chat-widget.open .chat-launcher { opacity: 0; pointer-events: none; transform: scale(0.8); }

.chat-panel {
    position: fixed; right: 22px; bottom: 22px; z-index: 61; display: flex; flex-direction: column;
    width: min(390px, calc(100vw - 32px)); height: min(620px, calc(100vh - 110px)); overflow: hidden;
    border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--surface);
    box-shadow: 0 28px 70px rgba(5, 2, 14, 0.7), 0 0 0 1px rgba(155, 107, 255, 0.12);
    animation: chat-in 0.22s ease-out;
}
.chat-panel[hidden] { display: none; }
@keyframes chat-in { from { opacity: 0; transform: translateY(16px) scale(0.98); } to { opacity: 1; transform: none; } }
.chat-head {
    display: flex; align-items: center; gap: 12px; padding: 14px 14px 14px 16px;
    background: radial-gradient(circle at 0 0, rgba(155, 107, 255, 0.45), transparent 60%), linear-gradient(135deg, #2a1660, #1d1240);
    border-bottom: 1px solid var(--border-strong);
}
.chat-head-avatar { position: relative; display: grid; place-items: center; flex: none; width: 42px; height: 42px; border-radius: 50%; background: linear-gradient(135deg, var(--gold), var(--gold-strong)); color: var(--gold-ink); font-size: 1.2rem; }
.chat-head-avatar .presence-dot { position: absolute; right: -1px; bottom: -1px; border: 2px solid #241848; box-shadow: none; }
.chat-head-text { display: grid; flex: 1; min-width: 0; }
.chat-head-text strong { font: 600 1rem var(--font-brand); }
.chat-head-text small { overflow: hidden; color: var(--ink-2); font-size: 0.78rem; text-overflow: ellipsis; white-space: nowrap; }
.chat-head-actions { display: flex; gap: 4px; }
.chat-icon { display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 10px; background: rgba(255, 255, 255, 0.06); color: var(--ink-2); cursor: pointer; }
.chat-icon:hover { background: rgba(255, 255, 255, 0.14); color: var(--ink); }
.chat-icon:focus-visible { outline: none; box-shadow: var(--focus); }
.chat-banner { margin: 0; padding: 7px 14px; background: rgba(250, 178, 25, 0.12); color: var(--warning-text); font-size: 0.8rem; text-align: center; }
.chat-scroll { flex: 1; overflow-y: auto; padding: 16px 14px; overscroll-behavior: contain; scrollbar-width: thin; }
.chat-welcome { display: grid; justify-items: center; gap: 4px; margin: 6px 0 16px; text-align: center; }
.chat-welcome[hidden] { display: none; }
.chat-welcome-icon { display: grid; place-items: center; width: 54px; height: 54px; margin-bottom: 6px; border-radius: 18px; background: var(--gold-soft); color: var(--gold); font-size: 1.5rem; }
.chat-welcome-title { margin: 0; font: 600 1.25rem var(--font-brand); }
.chat-welcome p { margin: 0; color: var(--ink-2); font-size: 0.88rem; max-width: 30ch; }
.chat-topics { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 12px 0 6px; }
.chat-topics button { padding: 7px 12px; border: 1px solid var(--border-strong); border-radius: 999px; background: rgba(255, 255, 255, 0.03); color: var(--ink); font: 600 0.8rem var(--font-ui); cursor: pointer; }
.chat-topics button:hover, .chat-topics button:focus-visible { border-color: var(--gold); background: var(--gold-soft); outline: none; }
.chat-ticket-link { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; color: var(--muted); font-size: 0.8rem; }
.chat-ticket-link:hover { color: var(--gold); }
.chat-ended { display: grid; justify-items: center; gap: 10px; margin-top: 16px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: rgba(255, 255, 255, 0.03); text-align: center; }
.chat-ended[hidden] { display: none; }
.chat-ended-title { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 700; }
.chat-ended-title i { color: var(--good-text); }
.chat-rate { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 0.86rem; }
.chat-rate[hidden], .chat-rated[hidden] { display: none; }
.chat-rate button { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--border-strong); border-radius: 50%; background: transparent; color: var(--ink-2); cursor: pointer; }
.chat-rate button:hover, .chat-rate button:focus-visible { border-color: var(--gold); color: var(--gold); outline: none; }
.chat-rated { margin: 0; color: var(--good-text); font-size: 0.86rem; }
.chat-compose { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); background: var(--page-2); }
.chat-compose[hidden] { display: none; }
.chat-compose textarea {
    flex: 1; min-height: 42px; max-height: 140px; padding: 10px 14px; resize: none;
    border: 1px solid var(--border-strong); border-radius: 21px; background: var(--surface); color: var(--ink); font: 0.92rem/1.4 var(--font-ui);
}
.chat-compose textarea:focus { outline: none; border-color: var(--gold); box-shadow: var(--focus); }
.chat-send { display: grid; place-items: center; flex: none; width: 42px; height: 42px; border: 0; border-radius: 50%; background: linear-gradient(135deg, var(--gold), var(--gold-strong)); color: var(--gold-ink); font-size: 1rem; cursor: pointer; }
.chat-send:disabled { opacity: 0.55; cursor: progress; }
.chat-send:focus-visible { outline: none; box-shadow: var(--focus); }
.chat-error { margin: 0; padding: 6px 14px 10px; background: var(--page-2); color: var(--critical-text); font-size: 0.8rem; }

/* ---------- Agent console ---------- */
.console-status { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 10px; color: var(--ink-2); font-size: 0.88rem; font-weight: 600; }
.chat-console {
    display: grid; grid-template-columns: 300px minmax(0, 1fr) 260px; min-height: 560px; height: calc(100vh - 250px);
    overflow: hidden; border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--surface);
}
.console-list { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--border); background: var(--page-2); }
.console-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 10px; border-bottom: 1px solid var(--border); }
.console-tabs button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 6px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--muted); font: 700 0.8rem var(--font-ui); cursor: pointer; }
.console-tabs button[aria-selected="true"] { background: var(--raised-2); color: var(--ink); }
.console-tabs button:focus-visible { outline: none; box-shadow: var(--focus); }
.console-items { flex: 1; overflow-y: auto; margin: 0; padding: 6px; list-style: none; }
.console-items:empty { display: none; }
.console-item {
    display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 10px; align-items: center; width: 100%; padding: 10px;
    border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent; color: var(--ink); font: inherit; text-align: left; cursor: pointer;
}
.console-item:hover { background: var(--raised); }
.console-item.selected { border-color: rgba(255, 201, 77, 0.45); background: var(--gold-soft); }
.console-item:focus-visible { outline: none; box-shadow: var(--focus); }
.console-item .avatar, .console-head .avatar {
    display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg, var(--violet-strong), var(--magenta)); color: #fff; font-weight: 800;
}
.console-item-main { display: grid; gap: 1px; min-width: 0; }
.console-item-main strong { overflow: hidden; font-size: 0.9rem; text-overflow: ellipsis; white-space: nowrap; }
.console-item-main small { overflow: hidden; color: var(--muted); font-size: 0.78rem; text-overflow: ellipsis; white-space: nowrap; }
.console-item.unread .console-item-main small { color: var(--ink); font-weight: 600; }
.console-item-side { display: grid; justify-items: end; gap: 3px; }
.console-item-side time { color: var(--muted); font-size: 0.7rem; white-space: nowrap; }
.console-item .count { padding: 0 0.42rem; border-radius: 999px; font-size: 0.7rem; font-weight: 800; }
.console-item-agent { color: var(--muted); font-size: 0.68rem; }
.console-empty { flex: 1; display: grid; place-content: center; justify-items: center; gap: 6px; padding: 30px 16px; color: var(--muted); font-size: 0.86rem; text-align: center; }
.console-empty[hidden] { display: none; }
.console-empty i { color: var(--gold); font-size: 1.6rem; }
.console-empty p { margin: 0; }

.console-chat { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.console-placeholder { display: grid; place-content: center; justify-items: center; gap: 6px; height: 100%; padding: 24px; color: var(--muted); text-align: center; }
.console-placeholder[hidden] { display: none; }
.console-placeholder i { color: var(--gold); font-size: 2.2rem; }
.console-placeholder h3 { margin: 4px 0 0; color: var(--ink); }
.console-placeholder p { margin: 0; max-width: 40ch; }
.console-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.console-head[hidden] { display: none; }
.console-head-who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.console-head-who div { display: grid; min-width: 0; }
.console-head-who small { color: var(--muted); font-size: 0.78rem; }
.console-head-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.console-head-actions [hidden] { display: none; }
.console-log-wrap { flex: 1; overflow-y: auto; padding: 16px; }
.console-compose { display: grid; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); background: var(--page-2); }
.console-compose[hidden] { display: none; }
.console-compose .canned { justify-self: start; }
.console-compose-row { display: flex; align-items: flex-end; gap: 8px; }
.console-compose textarea {
    flex: 1; min-height: 46px; max-height: 160px; padding: 10px 12px; resize: vertical;
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font: 0.92rem/1.4 var(--font-ui);
}
.console-compose textarea:focus { outline: none; border-color: var(--gold); box-shadow: var(--focus); }
.console-player { overflow-y: auto; padding: 16px; border-left: 1px solid var(--border); background: var(--page-2); }
.console-player[hidden] { display: block; visibility: hidden; }

/* ---------- Small screens ---------- */
@media (max-width: 1180px) {
    .chat-console { grid-template-columns: 260px minmax(0, 1fr); }
    .console-player, .console-player[hidden] { display: none; }
}

@media (max-width: 960px) {
    .help-hero { grid-template-columns: minmax(0, 1fr); }
    .chat-widget { right: 14px; bottom: calc(78px + env(safe-area-inset-bottom)); }
    .chat-launcher { height: 50px; padding: 0 16px 0 14px; }
    .chat-panel { inset: 0; right: 0; bottom: 0; width: 100%; height: 100%; height: 100dvh; border: 0; border-radius: 0; z-index: 1060; }
    .chat-compose { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
    .chat-console { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(420px, 1fr); height: auto; }
    .console-list { max-height: 300px; border-right: 0; border-bottom: 1px solid var(--border); }
    .ticket-row { flex-wrap: wrap; }
    .ticket-side { justify-content: flex-start; width: 100%; padding-left: 52px; }
    .thread-message { grid-template-columns: 32px minmax(0, 1fr); gap: 8px; }
    .thread-avatar { width: 32px; height: 32px; font-size: 0.85rem; }
    .file-thumb { width: 110px; height: 80px; }
}

@media (max-width: 560px) {
    .chat-launcher-label { display: none; }
    .chat-launcher { width: 54px; padding: 0; justify-content: center; }
    .desk-filters select, .desk-filters input[type="search"] { flex: 1 1 100%; min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .presence-dot.on, .chat-launcher.has-unread, .chat-typing .dots i, .chat-panel { animation: none; }
    .help-option, .chat-launcher, .file-thumb img { transition: none; }
}
