/* Persistent people-and-group conversations, separate from the learner guide. */
body.km-enabled .main { padding-bottom: calc(112px + env(safe-area-inset-bottom, 0px)); }
.km-dock {
  position: fixed;
  right: max(20px, env(safe-area-inset-right, 0px));
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  z-index: 100;
  font-family: var(--font-body);
  color: var(--ink);
  pointer-events: none;
}
.km-dock [hidden], .km-panel[hidden] { display: none !important; }
.km-launch, .km-panel { pointer-events: auto; }
.km-launch {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-left: auto;
  min-height: 52px;
  max-width: min(240px, calc(100vw - 172px));
  padding: 11px 16px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent);
  color: var(--card);
  font: 700 14px/1.3 var(--font-body);
  overflow-wrap: anywhere;
  cursor: pointer;
  box-shadow: 0 5px 14px #101a2e24, 0 14px 34px #101a2e1a;
}
.km-launch svg { width: 23px; height: 23px; flex: none; }
.km-launch > span:not(.km-count) { white-space: nowrap; }
.km-launch:hover { box-shadow: 0 0 0 3px var(--accent-soft), 0 8px 24px #101a2e26; }
.km-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  min-height: 22px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font: 700 11px/1.25 var(--font-body);
  flex: none;
}
.km-launch .km-count { background: var(--card); color: var(--ink); }
.km-panel {
  position: absolute;
  right: 0;
  bottom: 68px;
  display: flex;
  flex-direction: column;
  width: 420px;
  max-width: calc(100vw - 40px);
  height: min(660px, calc(100vh - 108px - env(safe-area-inset-bottom, 0px)));
  height: min(660px, calc(100dvh - 108px - env(safe-area-inset-bottom, 0px) - env(safe-area-inset-top, 0px)));
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  box-shadow: 0 8px 24px #101a2e1f, 0 24px 64px #101a2e38;
  font-size: 13px;
  line-height: 1.5;
}
.km-header {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 72px;
  padding: 12px 14px 10px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}
.km-header > :first-child { min-width: 0; }
.km-header strong { display: block; font-size: 17px; line-height: 1.3; font-weight: 700; }
.km-identity { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.km-icon, .km-button, .km-tab, .km-send, .km-hide {
  appearance: none;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--card);
  color: var(--ink);
  font: 600 12px/1.4 var(--font-body);
  cursor: pointer;
}
.km-icon { display: inline-flex; align-items: center; justify-content: center; width: 44px; padding: 9px; flex: none; }
.km-icon svg, .km-send svg { width: 20px; height: 20px; flex: none; }
.km-button { padding: 9px 12px; overflow-wrap: anywhere; }
.km-icon:hover, .km-button:hover, .km-hide:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.km-tabs { flex: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; padding: 6px 12px; border-bottom: 1px solid var(--line); }
.km-tab { border-color: transparent; padding: 8px; background: transparent; color: var(--muted); }
.km-tab[aria-selected="true"] { color: var(--accent); background: var(--accent-soft); }
.km-tab:hover { border-color: var(--accent); color: var(--accent); }
.km-body, .km-list-view, .km-thread-view { display: flex; flex-direction: column; flex: 1; min-height: 0; min-width: 0; }
.km-body { overflow: hidden; }
.km-toolbar { flex: none; display: flex; align-items: center; gap: 8px; padding: 12px; border-bottom: 1px solid var(--line); }
.km-search { display: flex; align-items: center; flex: 1; min-width: 0; position: relative; }
.km-search > svg { position: absolute; left: 11px; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.km-search input, input.km-search, .km-input {
  appearance: none;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--bg);
  font: 400 14px/1.45 var(--font-body);
}
.km-search:has(> svg) input { padding-left: 36px; }
.km-search input::placeholder, input.km-search::placeholder, .km-input::placeholder { color: var(--muted); opacity: 1; }
.km-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.km-row {
  appearance: none;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 78px;
  padding: 12px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: var(--card);
  color: var(--ink);
  text-align: left;
  font: 400 13px/1.45 var(--font-body);
  cursor: pointer;
}
.km-row:hover, .km-row[aria-current="true"] { background: var(--accent-soft); }
.km-avatar { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700; flex: none; }
.km-row-text { display: grid; gap: 3px; min-width: 0; }
.km-row > .km-row-text:only-child { grid-column: 1 / -1; }
.km-row-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 650; }
.km-preview { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12px; }
.km-row-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 7px; max-width: 74px; }
.km-time { display: block; color: var(--muted); font-size: 10.5px; line-height: 1.4; overflow-wrap: anywhere; }
.km-thread-head { flex: none; display: flex; align-items: center; gap: 10px; min-height: 64px; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.km-thread-title { min-width: 0; flex: 1; overflow-wrap: anywhere; font-size: 13px; font-weight: 650; }
.km-thread-title strong { display: block; }
.km-thread-title small { display: block; color: var(--muted); font-size: 11px; font-weight: 400; }
.km-status, .km-notice { flex: none; margin: 0; padding: 9px 14px; color: var(--ink); background: var(--warn-soft); border-bottom: 1px solid var(--line); font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; max-height: 96px; overflow-y: auto; }
.km-notice { background: var(--accent-soft); }
.km-log { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; padding: 14px 12px; background: var(--bg); }
.km-bubble { align-self: flex-start; flex: none; width: fit-content; max-width: 89%; padding: 10px 12px 8px; border: 1px solid var(--line); border-radius: 13px 13px 13px 4px; background: var(--card); color: var(--ink); overflow-wrap: anywhere; }
.km-bubble.km-mine { align-self: flex-end; border-color: var(--accent); border-radius: 13px 13px 4px 13px; background: var(--accent-soft); }
.km-author { display: block; font-size: 11px; font-weight: 650; color: var(--accent); }
.km-text { margin: 4px 0 7px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; line-height: 1.5; }
.km-hide { display: block; padding: 7px 8px; margin: 5px 0 0 auto; min-height: 40px; background: transparent; color: var(--muted); font-size: 10.5px; }
.km-compose { display: flex; align-items: flex-end; gap: 8px; flex: none; margin: 0; padding: 10px 12px; border-top: 1px solid var(--line); background: var(--card); }
.km-compose .km-input { flex: 1; height: 64px; min-height: 48px; max-height: 128px; resize: vertical; }
.km-send { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 44px; padding: 11px; background: var(--accent); border-color: var(--accent); color: var(--card); flex: none; }
.km-send:hover { box-shadow: 0 0 0 3px var(--accent-soft); }
.km-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; flex: none; padding: 8px 12px; border-top: 1px solid var(--line); }
.km-policy { flex: none; max-height: min(150px, 25dvh); overflow-y: auto; padding: 0 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.km-policy summary { min-height: 40px; padding: 11px 0; color: var(--muted); cursor: pointer; }
.km-policy p { margin: 0 0 10px; }
.km-footer { flex: none; margin: 0; padding: 7px 14px 10px; border-top: 1px solid var(--line); color: var(--muted); background: var(--card); font-size: 10.5px; line-height: 1.45; overflow-wrap: anywhere; }
.km-footer small { font: inherit; }
.km-empty { margin: 0; padding: 26px 20px; color: var(--muted); font-size: 13px; text-align: center; overflow-wrap: anywhere; }
.km-dock :is(button, input, textarea, summary):focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.km-row:focus-visible { outline-offset: -3px; }
.km-launch:focus-visible { outline-offset: 4px; }
.km-dock button:disabled, .km-dock textarea:disabled { background: var(--bg); color: var(--muted); border-color: var(--line); cursor: not-allowed; box-shadow: none; }
@media (max-width: 600px) {
  .km-dock { left: max(12px, env(safe-area-inset-left, 0px)); right: max(12px, env(safe-area-inset-right, 0px)); bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
  .km-panel { width: 100%; max-width: none; bottom: 68px; height: min(620px, calc(100vh - 110px)); height: min(620px, calc(100dvh - 110px - env(safe-area-inset-bottom, 0px) - env(safe-area-inset-top, 0px))); }
  .km-header { padding-left: 14px; }
  .km-launch { min-height: 52px; padding: 10px 13px; gap: 7px; }
  .km-search input, input.km-search, .km-input { font-size: 16px; }
  .km-row { gap: 9px; padding: 11px 12px; }
  .km-compose { padding: 9px 10px; }
  .km-bubble { max-width: 92%; }
}
@media (max-height: 600px) {
  .km-header { min-height: 56px; padding-top: 6px; padding-bottom: 6px; }
  .km-tabs { padding-top: 3px; padding-bottom: 3px; }
  .km-thread-head { min-height: 54px; padding-top: 5px; padding-bottom: 5px; }
  .km-footer { padding-top: 5px; padding-bottom: 5px; }
  .km-status, .km-notice { max-height: 55px; }
  .km-compose .km-input { height: 48px; }
}
@media (max-height: 480px) {
  .km-header { min-height: 44px; padding: 0 8px 0 12px; }
  .km-header strong { font-size: 15px; }
  .km-header > div { display: flex; flex-wrap: wrap; align-items: baseline; gap: 1px 7px; }
  .km-identity { margin-top: 0; font-size: 11px; }
  .km-tabs { padding-top: 0; padding-bottom: 0; }
  .km-thread-view { display: block; overflow-y: auto; overscroll-behavior: contain; }
  .km-thread-head { min-height: 44px; padding: 0 10px; }
  .km-status, .km-notice { max-height: 32px; padding: 4px 12px; font-size: 11px; }
  .km-log { height: 120px; min-height: 80px; max-height: 32dvh; }
  .km-compose { position: sticky; bottom: 0; z-index: 1; padding-top: 6px; padding-bottom: 6px; }
  .km-policy { max-height: none; }
}
@media (max-width: 380px) {
  .km-launch { gap: 6px; padding-right: 11px; padding-left: 11px; font-size: 13px; }
  .km-launch svg { width: 21px; height: 21px; }
}
@media print { .km-dock { display: none !important; } body.km-enabled .main { padding-bottom: 0; } }
