/* support-widget.css — Knox Support button + panel (support-widget.js). */

/* ── Round button beside the message box ──
   Lives in #inputOuter, right of the 900px input bar, so it only shows when
   there's room for it; phones and narrow windows reach it from the profile
   menu (Help & support). */
#inputOuter { container-type: inline-size; container-name: knoxinput; }
#ksLauncher {
  display: none; position: absolute; right: 22px; top: 50%; transform: translateY(-50%);
  width: 56px; height: 56px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--orange); color: #fff; box-shadow: 0 4px 0 var(--orange-dark), 0 10px 24px rgba(255,107,0,.28);
  align-items: center; justify-content: center; transition: transform .15s, box-shadow .15s; z-index: 2;
}
#ksLauncher:hover { transform: translateY(calc(-50% - 2px)); box-shadow: 0 6px 0 var(--orange-dark), 0 14px 28px rgba(255,107,0,.32); }
#ksLauncher:active { transform: translateY(calc(-50% + 2px)); box-shadow: 0 2px 0 var(--orange-dark); }
#ksLauncher:focus-visible { outline: 3px solid var(--orange-light); outline-offset: 3px; }
@container knoxinput (min-width: 1060px) { #ksLauncher { display: flex; } }
body.knox-flashcards #ksLauncher { display: none; }
.ks-l-icon { position: absolute; display: flex; transition: transform .2s, opacity .2s; }
.ks-l-down { opacity: 0; transform: rotate(-90deg) scale(.6); }
#ksLauncher.open .ks-l-chat { opacity: 0; transform: rotate(90deg) scale(.6); }
#ksLauncher.open .ks-l-down { opacity: 1; transform: none; }
.ks-badge {
  position: absolute; top: -3px; right: -3px; min-width: 21px; height: 21px; padding: 0 5px; border-radius: 11px;
  background: var(--red); color: #fff; font-size: 12px; font-weight: 900; line-height: 21px; text-align: center;
  border: 2.5px solid var(--cream);
}
.ks-badge[hidden] { display: none; }
.ks-beta {
  display: inline-block; vertical-align: 2px; margin-left: 4px; padding: 1px 7px; border-radius: 999px;
  background: var(--purple-dark, #7C3AED); color: #fff; font-style: normal;
  font-size: 10px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; line-height: 15px;
}
.ks-brand { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 900; }
.ks-hero .ks-beta { background: rgba(255,255,255,.95); color: var(--orange-dark); }

/* ── Panel ── */
#ksPanel {
  --ks-bg: var(--cream); --ks-card: var(--surface);
  position: fixed; right: 24px; bottom: 112px; z-index: 9000;
  width: 390px; height: min(680px, calc(100vh - 140px)); height: min(680px, calc(100dvh - 140px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--ks-bg); color: var(--text);
  border: 2px solid var(--border); border-radius: 24px;
  box-shadow: 0 6px 0 var(--border), 0 24px 60px rgba(0,0,0,.18);
  opacity: 0; transform: translateY(14px) scale(.98); transform-origin: bottom right;
  transition: opacity .18s ease, transform .18s ease;
  font-family: 'Nunito', system-ui, -apple-system, sans-serif;
}
#ksPanel[hidden] { display: none; }
#ksPanel.show { opacity: 1; transform: none; }
.ks-body { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; overscroll-behavior: contain; }
#ksPanel.in-chat .ks-body { overflow: hidden; }
#ksPanel img { display: block; }
#ksPanel button { font-family: inherit; }

/* Home */
.ks-hero {
  position: relative; padding: 22px 22px 70px; color: #fff; flex-shrink: 0;
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(206,130,255,.75) 0%, transparent 55%),
    radial-gradient(100% 80% at 0% 10%, rgba(255,217,0,.45) 0%, transparent 60%),
    linear-gradient(160deg, #FF8A2B 0%, var(--orange) 55%, #E85D00 100%);
}
.ks-hero::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 60px; background: linear-gradient(to bottom, transparent, var(--ks-bg)); }
.ks-hero-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 30px; }
.ks-hero-top img { width: 42px; height: 42px; border-radius: 12px; border: 2.5px solid rgba(255,255,255,.85); }
.ks-hero .ks-x { color: #fff; }
.ks-hero .ks-x:hover { background: rgba(255,255,255,.18); }
.ks-hi { margin: 0; font-size: 27px; font-weight: 900; opacity: .78; letter-spacing: -.01em; }
.ks-how { margin: 2px 0 0; font-size: 27px; font-weight: 900; letter-spacing: -.01em; line-height: 1.15; }
.ks-cards { position: relative; z-index: 1; margin-top: -54px; padding: 0 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.ks-card {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; text-align: left; width: 100%;
  padding: 15px 16px; border-radius: 18px; background: var(--ks-card); color: var(--text);
  border: 2px solid var(--border); box-shadow: 0 3px 0 var(--border); text-decoration: none; cursor: pointer;
  transition: border-color .15s, transform .15s;
}
button.ks-card:hover, a.ks-card:hover { border-color: var(--orange); }
.ks-card > span:first-child { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ks-card b { font-size: 15.5px; font-weight: 900; }
.ks-card b + span { font-size: 13.5px; font-weight: 700; color: var(--text-light); }
.ks-ask { border-color: var(--orange-light); }
.ks-ask-go { width: 38px; height: 38px; flex-shrink: 0; border-radius: 12px; display: grid; place-items: center; background: var(--orange); color: #fff; box-shadow: 0 3px 0 var(--orange-dark); }
.ks-recent { flex-direction: column; align-items: stretch; gap: 8px; }
.ks-card-label { font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: .06em; color: var(--text-light); }
.ks-recent-row { display: flex; align-items: center; gap: 10px; }
.ks-recent-row img, .ks-conv > img, .ks-msg.them > img, .ks-head-who img, .ks-empty img { width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0; }
.ks-recent-text { display: flex; flex-direction: column; min-width: 0; flex: 1; font-size: 13.5px; }
.ks-recent-text b { font-size: 13.5px; }
.ks-recent-text span { color: var(--text-light); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ks-search-card { flex-direction: column; align-items: stretch; gap: 0; padding: 8px; cursor: default; }
.ks-search-btn {
  display: flex; align-items: center; justify-content: space-between; padding: 12px 12px; border-radius: 12px; border: none; cursor: pointer;
  background: var(--gray); color: var(--text); font-size: 15px; font-weight: 900; margin-bottom: 4px;
}
.ks-search-btn svg { color: var(--orange); }
.ks-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 12px; border: none; border-radius: 10px;
  background: transparent; color: var(--text-light); font-size: 14.5px; font-weight: 700; text-align: left; cursor: pointer;
}
.ks-row:hover { background: var(--gray); color: var(--text); }
.ks-row svg, .ks-link svg { color: var(--orange); flex-shrink: 0; }

/* Shared header */
.ks-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 14px 12px 20px; border-bottom: 2px solid var(--border); background: var(--ks-card); flex-shrink: 0; }
.ks-head h2 { margin: 0; font-size: 18px; font-weight: 900; }
.ks-head.chat { padding-left: 8px; }
.ks-head-who { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; }
.ks-head-who > span { display: flex; flex-direction: column; min-width: 0; }
.ks-head-who b { font-size: 15.5px; font-weight: 900; }
.ks-head-who b + span { font-size: 12.5px; font-weight: 700; color: var(--text-light); }
.ks-x { width: 38px; height: 38px; flex-shrink: 0; display: grid; place-items: center; border: none; border-radius: 12px; background: transparent; color: var(--text-light); cursor: pointer; }
.ks-x:hover { background: var(--gray); color: var(--text); }

/* Messages list */
.ks-convs { display: flex; flex-direction: column; padding: 6px 8px; }
.ks-conv { display: flex; align-items: flex-start; gap: 12px; padding: 12px; border: none; border-radius: 14px; background: transparent; color: var(--text); text-align: left; cursor: pointer; position: relative; }
.ks-conv:hover { background: var(--ks-card); }
.ks-conv-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ks-conv-top { display: flex; justify-content: space-between; gap: 8px; }
.ks-conv-top b { font-size: 14.5px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ks-conv-top time { font-size: 12px; font-weight: 700; color: var(--text-light); flex-shrink: 0; }
.ks-conv-last { font-size: 13.5px; font-weight: 600; color: var(--text-light); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ks-conv.unread .ks-conv-top b, .ks-conv.unread .ks-conv-last { font-weight: 900; color: var(--text); }
.ks-tag { align-self: flex-start; margin-top: 4px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 900; background: var(--gray); color: var(--text-light); }
.ks-tag.wait { background: var(--orange-light); color: var(--orange-dark); }
.ks-tag.replied { background: var(--green-light); color: var(--green-dark); }
.ks-pill-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); flex-shrink: 0; align-self: center; }
.ks-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 30px 28px; text-align: center; }
.ks-empty img { width: 56px; height: 56px; border-radius: 16px; margin-bottom: 4px; }
.ks-empty b { font-size: 17px; font-weight: 900; }
.ks-empty > span { font-size: 14px; font-weight: 700; color: var(--text-light); line-height: 1.45; }
.ks-small { font-size: 13px; font-weight: 700; color: var(--text-light); }
.ks-small a, .ks-article a, .ks-bubble a { color: var(--orange); font-weight: 800; }
.ks-foot { margin-top: auto; padding: 12px 16px 14px; display: flex; justify-content: center; }
.ks-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 18px; border: none; border-radius: 14px; cursor: pointer;
  background: var(--orange); color: #fff; font-size: 14.5px; font-weight: 900; box-shadow: 0 3px 0 var(--orange-dark); transition: transform .1s, box-shadow .1s;
}
.ks-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 0 var(--orange-dark); }
.ks-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--orange-dark); }
.ks-btn.ghost { background: transparent; color: var(--text-light); box-shadow: none; }
.ks-btn:disabled { opacity: .6; cursor: default; }
.ks-loading { display: flex; justify-content: center; gap: 6px; padding: 40px; }
.ks-loading i, .ks-typing i { width: 8px; height: 8px; border-radius: 50%; background: var(--orange); opacity: .35; animation: ksDot 1s infinite; }
.ks-loading i:nth-child(2), .ks-typing i:nth-child(2) { animation-delay: .15s; }
.ks-loading i:nth-child(3), .ks-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes ksDot { 0%, 60%, 100% { opacity: .3; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }

/* Chat */
.ks-thread { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 14px 10px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; }
.ks-msg { display: flex; gap: 8px; max-width: 88%; }
.ks-msg.me { align-self: flex-end; }
.ks-msg.them > img { width: 28px; height: 28px; border-radius: 9px; margin-top: 18px; }
.ks-who { display: block; font-size: 11.5px; font-weight: 800; color: var(--text-light); margin: 0 0 3px 4px; }
.ks-who i { font-style: normal; margin-left: 4px; padding: 1px 6px; border-radius: 999px; background: var(--green-light); color: var(--green-dark); font-size: 10.5px; }
.ks-bubble { padding: 10px 14px; border-radius: 18px; font-size: 14.5px; font-weight: 600; line-height: 1.5; overflow-wrap: anywhere; }
.ks-msg.them .ks-bubble { background: var(--ks-card); border: 2px solid var(--border); border-top-left-radius: 6px; }
.ks-msg.team .ks-bubble { border-color: var(--green); }
.ks-msg.me .ks-bubble { background: var(--orange); color: #fff; border-bottom-right-radius: 6px; }
.ks-msg.me .ks-bubble a { color: #fff; text-decoration: underline; }
.ks-typing { display: flex; gap: 5px; padding: 14px 16px; }
.ks-note { align-self: center; max-width: 92%; text-align: center; padding: 8px 14px; border-radius: 14px; background: var(--orange-light); color: var(--text); font-size: 13px; font-weight: 800; line-height: 1.45; }
.ks-err { align-self: center; padding: 8px 12px; border-radius: 12px; background: var(--danger-bg); color: var(--red); font-size: 13px; font-weight: 800; text-align: center; }
.ks-starters { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: auto; padding-top: 8px; }
.ks-starters button {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 13px; border-radius: 999px; cursor: pointer;
  border: 2px solid var(--orange); background: var(--ks-card); color: var(--orange-dark); font-size: 13.5px; font-weight: 800;
}
.ks-starters button:hover { background: var(--orange); color: #fff; }
.ks-action { display: flex; flex-direction: column; gap: 4px; padding: 14px; border-radius: 16px; background: var(--ks-card); border: 2px solid var(--orange); box-shadow: 0 3px 0 var(--orange-dark); }
.ks-action b { font-size: 14.5px; font-weight: 900; }
.ks-action > span { font-size: 13px; font-weight: 700; color: var(--text-light); }
.ks-action > div { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.ks-person { align-self: center; margin: 0 0 6px; padding: 6px 12px; border: none; border-radius: 999px; background: transparent; color: var(--text-light); font-size: 13px; font-weight: 800; cursor: pointer; flex-shrink: 0; }
.ks-person:hover { background: var(--gray); color: var(--text); }
.ks-compose { display: flex; align-items: flex-end; gap: 8px; margin: 0 12px 12px; padding: 6px 6px 6px 14px; border: 2px solid var(--border); border-radius: 18px; background: var(--ks-card); flex-shrink: 0; }
.ks-compose:focus-within { border-color: var(--orange); }
.ks-compose textarea { flex: 1; min-width: 0; resize: none; border: none; outline: none; background: transparent; color: var(--text); font: inherit; font-size: 15px; font-weight: 600; line-height: 1.4; padding: 8px 0; max-height: 120px; }
.ks-compose button { width: 38px; height: 38px; flex-shrink: 0; border: none; border-radius: 12px; display: grid; place-items: center; background: var(--orange); color: #fff; cursor: pointer; box-shadow: 0 3px 0 var(--orange-dark); }
.ks-compose button:disabled { opacity: .5; }

/* Help */
.ks-help { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.ks-search { display: flex; align-items: center; gap: 8px; padding: 11px 14px; border: 2px solid var(--border); border-radius: 14px; background: var(--ks-card); color: var(--orange); }
.ks-search:focus-within { border-color: var(--orange); }
.ks-search input { flex: 1; min-width: 0; border: none; outline: none; background: transparent; color: var(--text); font: inherit; font-size: 15px; font-weight: 700; }
.ks-articles { display: flex; flex-direction: column; gap: 8px; }
.ks-article { border: 2px solid var(--border); border-radius: 14px; background: var(--ks-card); box-shadow: 0 2px 0 var(--border); }
.ks-article summary { list-style: none; cursor: pointer; padding: 12px 40px 12px 14px; font-weight: 800; font-size: 14.5px; position: relative; }
.ks-article summary::-webkit-details-marker { display: none; }
.ks-article summary::after { content: '+'; position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font-size: 20px; font-weight: 900; color: var(--orange); }
.ks-article[open] summary::after { content: '–'; }
.ks-article[open] { border-color: var(--orange); box-shadow: 0 2px 0 var(--orange-dark); }
.ks-article p { margin: 0; padding: 0 14px 14px; font-size: 14px; line-height: 1.55; font-weight: 600; color: var(--text-light); }
.ks-still { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px; border-radius: 16px; background: var(--orange-light); }
.ks-still > span { display: flex; flex-direction: column; gap: 2px; font-size: 13px; font-weight: 700; color: var(--text-light); }
.ks-still b { font-size: 14.5px; color: var(--text); }

/* Bottom tabs */
.ks-nav { display: flex; border-top: 2px solid var(--border); background: var(--ks-card); flex-shrink: 0; }
#ksPanel.in-chat .ks-nav { display: none; }
.ks-nav button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 10px 0 11px; border: none; background: transparent; color: var(--text-light); font-size: 12.5px; font-weight: 900; cursor: pointer; position: relative; }
.ks-nav button.on { color: var(--orange); }
.ks-nav button:hover { color: var(--orange); }
.ks-dot { position: absolute; top: 7px; left: calc(50% + 8px); width: 9px; height: 9px; border-radius: 50%; background: var(--red); border: 2px solid var(--ks-card); }
.ks-dot[hidden] { display: none; }

/* Dark + fall */
html[data-theme="dark"] #ksPanel { box-shadow: 0 6px 0 rgba(0,0,0,.35), 0 24px 60px rgba(0,0,0,.5); }
html[data-theme="dark"] .ks-search-btn, html[data-theme="dark"] .ks-row:hover { background: rgba(255,255,255,.06); }
html[data-theme="dark"] .ks-starters button { color: #FFB074; }
html[data-theme="dark"] .ks-tag.wait { color: #FFB074; }
html.knox-seasonal .ks-hero {
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(201,120,55,.7) 0%, transparent 55%),
    radial-gradient(100% 80% at 0% 10%, rgba(255,196,0,.4) 0%, transparent 60%),
    linear-gradient(160deg, #F08A2C 0%, #D9621A 55%, #A9471A 100%);
}

/* Phones / narrow windows: full screen */
@media (max-width: 640px) {
  #ksPanel { inset: 0; width: auto; height: 100%; border-radius: 0; border: none; box-shadow: none; transform: translateY(24px); padding-bottom: env(safe-area-inset-bottom); }
  #ksPanel .ks-hero { padding-top: max(22px, env(safe-area-inset-top)); }
  #ksPanel .ks-head { padding-top: max(14px, env(safe-area-inset-top)); }
  html.ks-open, html.ks-open body { overflow: hidden; }
}
@media (prefers-reduced-motion: reduce) { #ksPanel, .ks-l-icon { transition: none; } }
