/* TechCom Brain floating assistant (manage/_ai_chat_widget.html) and the
   AI Settings page. Uses the portal tokens from app_v2.css. Layering: above
   page content, the mobile sidebar (50) and user menu (60), below every
   Portal modal (.mp-modal 80, .mp-lc-modal 120, dialogs 210+). */

.aic-widget {
  --aic-gap: 20px;
  --aic-launcher: 48px;
  --aic-lift: 0px;
  --aic-width: 460px;
  --aic-history: 280px;
  --aic-bottom: calc(var(--aic-gap) + var(--safe-bottom, 0px) + var(--aic-lift));
  --aic-panel-bottom: calc(var(--aic-bottom) + var(--aic-launcher) + 12px);
  font-family: var(--font, inherit);
}

.aic-widget[hidden],
.aic-root[hidden] {
  display: none;
}

.aic-sr-only,
.aic-model__select {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------------------------------------ launcher */

.aic-launcher {
  position: fixed;
  right: calc(var(--aic-gap) + var(--safe-right, 0px));
  bottom: var(--aic-bottom);
  z-index: 75;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--aic-launcher);
  height: var(--aic-launcher);
  padding: 0;
  /* Same dark glass as the sidebar (manage.css .mp-sidebar). */
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 50%;
  background: rgba(35, 33, 38, .9);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  color: var(--accent, #ff5a00);
  box-shadow: 0 8px 32px rgba(0, 0, 0, .12);
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, bottom .2s ease;
}

.aic-launcher:hover {
  transform: scale(1.06);
  box-shadow: 0 10px 36px rgba(0, 0, 0, .18);
}

.aic-launcher:active { transform: scale(.97); }

.aic-launcher:focus-visible,
.aic-root :focus-visible {
  outline: 2px solid var(--accent, #ff5a00);
  outline-offset: 2px;
}

.aic-launcher .aic-launcher__logo { width: 32px; height: 32px; background: transparent; box-shadow: none; }
.aic-launcher__close { display: none; color: #fff; }
.aic-widget.is-open .aic-launcher__logo { display: none; }
.aic-widget.is-open .aic-launcher__close { display: block; }

.aic-launcher__dot {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 11px;
  height: 11px;
  border: 2px solid #232126;
  border-radius: 50%;
  background: var(--accent, #ff5a00);
}

.aic-launcher__dot[hidden] { display: none; }

/* ------------------------------------------------------------ panel */

.aic-root {
  position: fixed;
  right: calc(var(--aic-gap) + var(--safe-right, 0px));
  bottom: var(--aic-panel-bottom);
  z-index: 75;
  display: grid;
  grid-template-columns: 0 minmax(0, 1fr);
  width: min(var(--aic-width), calc(100vw - 32px));
  height: min(max(440px, 60vh), calc(100vh - var(--aic-panel-bottom) - 16px));
  height: min(max(440px, 60dvh), calc(100dvh - var(--aic-panel-bottom) - 16px));
  border: 1px solid var(--border, rgba(17, 17, 17, .1));
  border-radius: 18px;
  box-sizing: border-box;
  background: var(--surface, #fff);
  box-shadow: 0 24px 60px rgba(17, 17, 17, .18), 0 4px 14px rgba(17, 17, 17, .08);
  overflow: hidden;
  color: var(--text, #111);
  opacity: 0;
  transform: translateY(10px) scale(.985);
  transform-origin: bottom right;
  transition: opacity .18s ease, transform .18s ease, width .22s ease;
}

.aic-root.is-visible {
  opacity: 1;
  transform: none;
}

.aic-root.has-history {
  grid-template-columns: var(--aic-history) minmax(0, 1fr);
  width: min(calc(var(--aic-width) + var(--aic-history)), calc(100vw - 32px));
}

/* ------------------------------------------------------------ history */

.aic-sidebar {
  grid-row: 1;
  grid-column: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 12px 8px 10px;
  border-right: 1px solid var(--border, rgba(17, 17, 17, .1));
  background: var(--bg, #f4f5f7);
  visibility: hidden;
  overflow: hidden;
}

.aic-sidebar.is-open { visibility: visible; }

@media (min-width: 821px) {
  .aic-root:not(.has-history) .aic-sidebar { padding: 0; border: 0; }
}

.aic-sidebar__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 4px 0 8px;
}

.aic-sidebar__title {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.aic-icon-btn.aic-sidebar__close { visibility: hidden; }

.aic-new {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 10px;
  padding: 9px 10px;
  border: 1px solid var(--border-hover, rgba(17, 17, 17, .2));
  border-radius: 10px;
  background: var(--surface, #fff);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}

.aic-new:hover { border-color: var(--accent, #ff5a00); color: var(--accent, #ff5a00); }

.aic-sidebar__empty {
  margin: 4px 8px;
  color: var(--muted);
  font-size: 13px;
}

.aic-convo-list {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.aic-convo {
  display: flex;
  align-items: center;
  border-radius: 10px;
}

.aic-convo:hover,
.aic-convo:focus-within { background: rgba(17, 17, 17, .05); }

.aic-convo.is-active {
  background: var(--accent-soft, rgba(255, 90, 0, .08));
  box-shadow: inset 3px 0 0 var(--accent, #ff5a00);
}

.aic-convo__open {
  flex: 1 1 auto;
  min-width: 0;
  padding: 9px 10px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.aic-convo.is-active .aic-convo__open { font-weight: 700; }

/* Row actions: a quiet "⋯" shown on hover or keyboard focus (always on
   touch screens), opening the Rename / Delete menu. */
.aic-convo__more {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-right: 4px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
}

.aic-convo:hover .aic-convo__more,
.aic-convo:focus-within .aic-convo__more,
.aic-convo.is-menu-open .aic-convo__more { opacity: 1; }

.aic-convo__more:hover,
.aic-convo.is-menu-open .aic-convo__more {
  background: rgba(17, 17, 17, .08);
  color: var(--text);
}

@media (hover: none) {
  .aic-convo__more { opacity: 1; width: 36px; height: 36px; }
}

.aic-convo-menu {
  position: absolute;
  z-index: 6;
  min-width: 148px;
  padding: 4px;
  border: 1px solid var(--border, rgba(17, 17, 17, .1));
  border-radius: 12px;
  background: var(--surface, #fff);
  box-shadow: 0 10px 28px rgba(17, 17, 17, .16);
}

.aic-convo-menu[hidden] { display: none; }

.aic-convo-menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}

.aic-convo-menu__item svg { flex: none; color: var(--muted); }
.aic-convo-menu__item:hover,
.aic-convo-menu__item:focus-visible { background: rgba(17, 17, 17, .06); outline: none; }
.aic-convo-menu__item--danger,
.aic-convo-menu__item--danger svg { color: #b42318; }
.aic-convo-menu__item--danger:hover,
.aic-convo-menu__item--danger:focus-visible { background: #fdf1ef; }

.aic-backdrop { display: none; }

/* ------------------------------------------------------------ main */

.aic-main {
  grid-row: 1;
  grid-column: 2; /* also when the history drawer is taken out of the grid */
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.aic-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.aic-icon-btn:hover,
.aic-icon-btn:focus-visible,
.aic-icon-btn.is-active {
  background: rgba(17, 17, 17, .07);
  color: var(--text);
}

.aic-icon-btn:disabled { cursor: not-allowed; opacity: .45; }

.aic-header {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 56px;
  padding: 8px 8px 8px 10px;
  border-bottom: 1px solid var(--border, rgba(17, 17, 17, .1));
  box-sizing: border-box;
}

.aic-header__center {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0 4px;
}

.aic-header__title {
  margin: 1px 0 0 8px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.aic-model { position: relative; }

.aic-model__btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 3px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.aic-model__btn:hover:not(:disabled),
.aic-model__btn[aria-expanded="true"] { background: rgba(17, 17, 17, .06); }
.aic-model__btn:disabled { cursor: default; }
.aic-model__btn:disabled .aic-model__chevron { opacity: .3; }

.aic-model__name {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.aic-model__chevron { flex: none; color: var(--muted); }

.aic-model__menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 5;
  width: max-content;
  min-width: 220px;
  max-width: min(320px, calc(100vw - 48px));
  max-height: 320px;
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  border: 1px solid var(--border, rgba(17, 17, 17, .1));
  border-radius: 14px;
  background: var(--surface, #fff);
  box-shadow: 0 12px 32px rgba(17, 17, 17, .16);
  list-style: none;
  outline: none;
}

.aic-model__menu[hidden] { display: none; }

.aic-model__option {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 32px 8px 10px;
  border-radius: 9px;
  cursor: pointer;
}

.aic-model__option:hover,
.aic-model__option.is-highlighted { background: rgba(17, 17, 17, .06); }

.aic-model__option[aria-selected="true"]::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 12px;
  width: 9px;
  height: 5px;
  margin-top: -4px;
  border-bottom: 2px solid var(--accent, #ff5a00);
  border-left: 2px solid var(--accent, #ff5a00);
  transform: rotate(-45deg);
}

.aic-model__option-name { font-size: 13.5px; font-weight: 600; }
.aic-model__option-desc { color: var(--muted); font-size: 12px; line-height: 1.35; }

.aic-banner {
  margin: 10px 12px 0;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.45;
}

.aic-banner[hidden] { display: none; }

.aic-banner--info {
  border: 1px solid #d7e2f0;
  background: #f2f6fb;
  color: #2b4766;
}

.aic-banner--error {
  border: 1px solid #f1c9c4;
  background: #fdf1ef;
  color: #8a2d1f;
}

.aic-thread {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 16px 6px;
}

.aic-welcome {
  margin: 14% auto 0;
  text-align: center;
}

.aic-welcome[hidden] { display: none; }

.aic-welcome h3 {
  margin: 4px 0 0;
  font-size: 21px;
  font-weight: 600;
}

.aic-messages {
  margin: 0;
  padding: 0;
  list-style: none;
}

.aic-loading {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

/* ------------------------------------------------------------ composer */

.aic-composer {
  margin: 4px 12px 12px;
  padding: 8px 8px 8px 12px;
  border: 1px solid var(--border-hover, rgba(17, 17, 17, .2));
  border-radius: 20px;
  background: var(--surface, #fff);
  box-sizing: border-box;
}

.aic-composer:focus-within {
  border-color: var(--accent, #ff5a00);
  box-shadow: 0 0 0 3px rgba(255, 90, 0, .12);
}

.aic-composer__input {
  display: block;
  width: 100%;
  min-height: 24px;
  max-height: 180px;
  padding: 4px 2px;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  line-height: 1.5;
  box-sizing: border-box;
}

.aic-composer__input:disabled { cursor: not-allowed; }
.aic-root .aic-composer__input:focus-visible { outline: none; } /* the composer shows focus */
.aic-composer__input[readonly] { caret-color: transparent; }

.aic-composer__bar {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
}

.aic-composer__hint {
  display: none; /* shown only when it says something that matters */
  flex: 1 1 auto;
  min-width: 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.35;
}

.aic-composer__hint.is-attention {
  display: block;
  color: #9a3412;
  font-weight: 600;
}

.aic-composer__count {
  margin-left: auto; /* the controls after it sit on the right */
  color: var(--muted);
  font-size: 11.5px;
}

.aic-composer__count.is-over {
  color: #b42318;
  font-weight: 700;
}

.aic-mic-lang {
  flex: none;
  height: 26px;
  padding: 0 6px;
  border: 1px solid var(--border, rgba(17, 17, 17, .1));
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .04em;
  cursor: pointer;
}

.aic-mic-lang:hover:not(:disabled) { color: var(--text); border-color: var(--border-hover, rgba(17, 17, 17, .2)); }
.aic-mic-lang:disabled { opacity: .45; cursor: default; }
.aic-mic-lang[hidden],
.aic-mic[hidden] { display: none; }

.aic-mic {
  border-radius: 50%;
}

.aic-mic[data-state="listening"],
.aic-mic[data-state="processing"] {
  background: var(--accent, #ff5a00);
  color: #fff;
}

.aic-mic[data-state="listening"] { animation: aic-listen 1.4s ease-out infinite; }
.aic-mic[data-state="processing"] { opacity: .7; }

@keyframes aic-listen {
  0% { box-shadow: 0 0 0 0 rgba(255, 90, 0, .45); }
  100% { box-shadow: 0 0 0 10px rgba(255, 90, 0, 0); }
}

.aic-send {
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin-left: 2px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--accent, #ff5a00);
  color: #fff;
  cursor: pointer;
  transition: background-color .15s ease, transform .15s ease;
}

.aic-send:hover:not(:disabled) { background: var(--accent-hover, #ff5000); transform: scale(1.05); }

.aic-send:disabled {
  background: rgba(17, 17, 17, .12);
  color: rgba(17, 17, 17, .45);
  cursor: not-allowed;
}

.aic-send__spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, .5);
  border-top-color: #fff;
  border-radius: 50%;
  animation: aic-spin .8s linear infinite;
}

.aic-send.is-busy { background: var(--accent, #ff5a00); color: #fff; }
.aic-send.is-busy .aic-send__arrow { display: none; }
.aic-send.is-busy .aic-send__spinner { display: block; }

@keyframes aic-spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------ AI Chat page */

.aic-web-result { font-size: 12.5px; }

.aic-page {
  max-width: 520px;
  margin: 12vh auto 0;
  text-align: center;
}

.aic-page__title { margin: 4px 0 16px; font-size: 24px; }

/* ------------------------------------------------------------ TechCom logo */

/* static/white_m_techcom.png is a white mark on a transparent canvas with
   wide margins: shown on a dark tile, scaled uniformly past those margins
   (never stretched). The chat's welcome logo has no tile, so it draws the
   same file black. */
.aic-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  overflow: hidden;
  border-radius: 9px;
  background: #111;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08);
}

.aic-logo img {
  display: block;
  flex: none;
  width: 170%;
  max-width: none;
  height: auto;
}

.aic-logo--header { margin: 0 2px 0 2px; }
.aic-logo--welcome { width: 52px; height: 52px; margin-bottom: 10px; border-radius: 0; background: transparent; box-shadow: none; }
.aic-logo--welcome img { filter: brightness(0); }
.aic-logo--page { width: 64px; height: 64px; margin-bottom: 12px; border-radius: 18px; }

/* ------------------------------------------------------------ expanded */

/* Expanded: the same panel (same DOM, conversation, uploads and polling)
   fills the window above the Portal's navigation and below its modals; the
   history is a left column on wide screens, the conversation a centred
   reading column with the composer at the bottom. */
.aic-expand__close { display: none; }
.aic-widget.is-expanded .aic-expand__open { display: none; }
.aic-widget.is-expanded .aic-expand__close { display: block; }

html.aic-expanded,
html.aic-expanded body { overflow: hidden; }

.aic-widget.is-expanded .aic-launcher { display: none; }

.aic-widget.is-expanded .aic-root {
  top: var(--aic-vvt, 0px);
  right: 0;
  bottom: auto;
  left: 0;
  width: 100%;
  height: 100vh;
  height: var(--aic-vvh, 100dvh);
  border: 0;
  border-radius: 0;
  box-shadow: none;
  transform: none;
  transition: opacity .18s ease;
}

.aic-widget.is-expanded .aic-header {
  min-height: 60px;
  padding: calc(8px + var(--safe-top, 0px)) 14px 8px;
}

.aic-widget.is-expanded .aic-thread { padding: 24px 20px 8px; }

.aic-widget.is-expanded .aic-messages,
.aic-widget.is-expanded .aic-welcome,
.aic-widget.is-expanded .aic-banner {
  max-width: 780px;
  margin-right: auto;
  margin-left: auto;
}

.aic-widget.is-expanded .aic-composer {
  width: min(780px, calc(100% - 32px));
  margin: 4px auto calc(16px + var(--safe-bottom, 0px));
}

@media (min-width: 821px) {
  .aic-widget.is-expanded .aic-root.has-history {
    grid-template-columns: var(--aic-history) minmax(0, 1fr);
    width: 100%;
  }
}

/* ------------------------------------------------------------ Personal Memory / Temporary Chat (2E) */

.aic-new--temp { margin-top: 6px; background: transparent; }

.aic-temp-pill {
  flex: 0 0 auto;
  padding: 3px 8px;
  border: 1px dashed var(--border-hover, rgba(17, 17, 17, .3));
  border-radius: 999px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
}

/* These controls have an explicit display; [hidden] must still win. */
.aic-icon-btn[hidden],
.aic-new[hidden],
.aic-temp-pill[hidden],
.aic-temp-toggle[hidden],
.aic-temp-note[hidden],
.aic-memory[hidden] { display: none; }

.aic-temp-toggle {
  margin-top: 14px;
  padding: 6px 12px;
  border: 1px dashed var(--border-hover, rgba(17, 17, 17, .3));
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.aic-temp-toggle[aria-pressed="true"] { border-style: solid; border-color: var(--text); color: var(--text); }

.aic-temp-note {
  margin: 0 12px 4px;
  padding: 8px 10px;
  border: 1px dashed var(--border-hover, rgba(17, 17, 17, .3));
  border-radius: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.aic-root.is-temporary .aic-composer { border-style: dashed; }

.aic-msg__note--memory { color: var(--muted); font-size: 12px; }

.aic-linkbtn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent, #ff5a00);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.aic-memory {
  position: absolute;
  inset: 56px 0 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface, #fff);
}

.aic-memory__bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border, rgba(17, 17, 17, .1));
}

.aic-memory__title { margin: 0; font-size: 15px; }
.aic-memory__body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 12px 16px 20px; }
.aic-memory__intro,
.aic-memory__hint { margin: 6px 0; color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.aic-memory__switch { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0; cursor: pointer; font-size: 13.5px; }
.aic-memory__switch input { margin-top: 3px; accent-color: var(--accent, #ff5a00); }
.aic-memory__switch-text { display: flex; flex-direction: column; gap: 2px; }
.aic-memory__status { min-height: 1em; margin: 4px 0; font-size: 12.5px; }
.aic-memory__status.is-error { color: #8a2d1f; }
.aic-memory__modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  margin: 8px 0 12px;
  padding: 3px;
  border-radius: 10px;
  background: var(--surface-muted, rgba(17, 17, 17, .06));
}
.aic-memory__mode { min-width: 0; padding: 7px 8px; border: 0; border-radius: 8px; background: transparent; font: inherit; cursor: pointer; }
.aic-memory__mode.is-active { background: var(--surface, #fff); box-shadow: 0 1px 3px rgba(17, 17, 17, .12); font-weight: 700; }
.aic-memory__section { margin-top: 14px; }
.aic-memory__h { margin: 0 0 6px; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; }
.aic-memory__facts,
.aic-memory__list { margin: 0; padding: 0; list-style: none; font-size: 13.5px; }
.aic-memory__facts li { margin: 2px 0; }

.aic-memory__item {
  margin: 6px 0;
  padding: 10px 12px;
  border: 1px solid var(--border, rgba(17, 17, 17, .1));
  border-radius: 12px;
}

.aic-memory__item.needs-review { border-style: dashed; }
.aic-memory__text { margin: 0; overflow-wrap: anywhere; line-height: 1.45; }
.aic-memory__meta { margin: 4px 0 0; color: var(--muted); font-size: 11.5px; }
.aic-memory__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.aic-memory__btn { min-height: 30px; padding: 4px 10px; font-size: 12.5px; }
.aic-memory__add { margin: 12px 0 4px; }

.aic-memory__input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid var(--border-hover, rgba(17, 17, 17, .2));
  border-radius: 10px;
  box-sizing: border-box;
  font: inherit;
  font-size: 13.5px;
  resize: vertical;
}

.aic-memory__select {
  flex: 1 1 140px;
  min-height: 30px;
  border: 1px solid var(--border-hover, rgba(17, 17, 17, .2));
  border-radius: 8px;
  background: var(--surface, #fff);
  font: inherit;
  font-size: 13px;
}

.aic-memory__clear { margin-top: 16px; color: #8a2d1f; }
.aic-import__title { margin: 10px 0 4px; font-size: 16px; }
.aic-import__source { min-height: 210px; resize: vertical; }
.aic-import__counter { display: block; margin: 4px 1px 0; color: var(--muted); font-size: 11.5px; text-align: right; }
.aic-import__counter.is-over { color: #8a2d1f; font-weight: 700; }
.aic-import__list { margin-top: 10px; }
.aic-import__candidate { min-width: 0; }
.aic-import__candidate.has-warning { border-color: rgba(190, 111, 0, .45); }
.aic-import__candidate-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 6px; }
.aic-import__check { display: flex; flex: 1 1 180px; min-width: 0; align-items: flex-start; gap: 7px; overflow-wrap: anywhere; }
.aic-import__check input { flex: 0 0 auto; margin-top: 3px; accent-color: var(--accent, #ff5a00); }
.aic-import__badge { max-width: 100%; padding: 2px 7px; border-radius: 999px; background: rgba(255, 90, 0, .1); color: var(--accent, #c94700); font-size: 11px; }
.aic-import__edit:disabled { opacity: 1; color: inherit; background: transparent; }
.aic-import__warning { margin: 7px 0 0; color: #8a5a00; font-size: 12px; line-height: 1.4; overflow-wrap: anywhere; }
.aic-import__coverage { display: grid; gap: 5px; margin: 10px 0; padding: 12px; border: 1px solid rgba(64, 124, 255, .24); border-radius: 12px; background: rgba(64, 124, 255, .07); }
.aic-import__coverage.is-incomplete { border-color: rgba(201, 119, 29, .38); background: rgba(201, 119, 29, .08); }
.aic-import__coverage-title, .aic-import__coverage-counts, .aic-import__coverage-categories { margin: 0; }
.aic-import__coverage-counts, .aic-import__coverage-categories { color: var(--aic-text, #1e293b); font-size: 12px; line-height: 1.45; }
.aic-import__replace { display: block; margin-top: 7px; font-size: 12px; line-height: 1.4; }
.aic-import__replace input { accent-color: var(--accent, #ff5a00); }
.aic-import__footer { position: sticky; bottom: -20px; margin: 12px -16px -20px; padding: 10px 16px 20px; background: var(--surface, #fff); border-top: 1px solid var(--border, rgba(17, 17, 17, .1)); }

.aic-widget.is-expanded .aic-memory { inset: calc(60px + var(--safe-top, 0px)) 0 0; }
.aic-widget.is-expanded .aic-memory__body { width: min(780px, 100%); margin: 0 auto; box-sizing: border-box; }
.aic-widget.is-expanded .aic-temp-note { width: min(780px, calc(100% - 32px)); margin: 0 auto 4px; box-sizing: border-box; }

@media (max-width: 600px) {
  .aic-memory__input { font-size: 16px; } /* no iOS zoom */
  .aic-memory__body { padding-right: 12px; padding-left: 12px; }
  .aic-import__footer { margin-right: -12px; margin-left: -12px; padding-right: 12px; padding-left: 12px; }
}

/* ------------------------------------------------------------ narrow screens */

/* History becomes a drawer over the conversation instead of widening the panel. */
@media (max-width: 820px) {
  .aic-root.has-history {
    grid-template-columns: 0 minmax(0, 1fr);
    width: min(var(--aic-width), calc(100vw - 32px));
  }

  .aic-sidebar {
    position: absolute;
    inset: 0 auto 0 0;
    z-index: 3;
    width: min(290px, 86%);
    box-shadow: 8px 0 24px rgba(17, 17, 17, .12);
    transform: translateX(-105%);
    transition: transform .2s ease, visibility .2s;
  }

  .aic-sidebar.is-open { transform: translateX(0); }

  .aic-icon-btn.aic-sidebar__close { visibility: visible; }

  .aic-backdrop:not([hidden]) {
    display: block;
    position: absolute;
    inset: 0;
    z-index: 2;
    background: rgba(17, 17, 17, .25);
  }

}

/* Phones: a full-height sheet inside the visible viewport (kept above the
   on-screen keyboard by --aic-vvh / --aic-vvt from visualViewport). */
@media (max-width: 600px) {
  .aic-widget { --aic-gap: 14px; --aic-launcher: 52px; }

  .aic-root {
    top: calc(var(--aic-vvt, 0px) + var(--safe-top, 0px));
    right: 0;
    bottom: auto;
    left: 0;
    width: 100%;
    height: calc(100vh - var(--safe-top, 0px));
    height: calc(var(--aic-vvh, 100dvh) - var(--safe-top, 0px));
    border-width: 1px 0 0;
    border-radius: 16px 16px 0 0;
    transform-origin: bottom center;
  }

  .aic-root.has-history { width: 100%; }

  .aic-widget.is-open .aic-launcher { display: none; }

  .aic-composer {
    margin-bottom: calc(10px + var(--safe-bottom, 0px));
  }

  .aic-composer__input { font-size: 16px; } /* prevents iOS zoom on focus */

  .aic-icon-btn,
  .aic-send { width: 40px; height: 40px; }

  .aic-mic-lang { height: 32px; }

  .aic-msg--user .aic-msg__bubble { max-width: 92%; }
}

@media (prefers-reduced-motion: reduce) {
  .aic-root,
  .aic-launcher,
  .aic-sidebar,
  .aic-send { transition: none; }
  .aic-launcher:hover,
  .aic-send:hover:not(:disabled) { transform: none; }
  .aic-root { transform: none; }
  .aic-mic[data-state="listening"] { animation: none; box-shadow: 0 0 0 3px rgba(255, 90, 0, .35); }
  .aic-send__spinner { animation-duration: 2s; }
}

/* ------------------------------------------------------------ messages */

.aic-msg {
  display: flex;
  flex-direction: column;
  margin: 0 0 18px;
}

.aic-msg--user {
  align-items: flex-end;
}

.aic-msg__bubble {
  max-width: 100%;
  font-size: 14.5px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.aic-msg--user .aic-msg__bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px 16px 4px 16px;
  background: var(--accent-soft, rgba(255, 90, 0, .08));
  white-space: pre-wrap;
}

.aic-msg.is-failed .aic-msg__bubble {
  padding: 10px 14px;
  border: 1px solid #f1c9c4;
  border-radius: 12px;
  background: #fdf1ef;
}

.aic-msg__error {
  margin: 0;
  color: #8a2d1f;
}

.aic-msg__retry {
  margin-top: 8px;
}

.aic-msg__note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  font-style: italic;
}

.aic-sources {
  margin: 6px 0 0;
  max-width: 100%;
  font-size: 12.5px;
}

.aic-sources__label {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
}

.aic-sources__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.aic-sources__item {
  display: flex;
  gap: 6px;
  align-items: baseline;
  min-width: 0;
}

.aic-sources__num {
  flex: none;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.aic-sources__link {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.aic-complete {
  display: grid;
  gap: 6px;
  margin: 6px 0 0;
  max-width: 100%;
}

.aic-complete__item {
  padding: 8px 10px;
  border: 1px solid currentColor;
  border-left-width: 3px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 12.5px;
}

.aic-complete__headline {
  margin: 0;
  font-weight: 600;
}

.aic-complete__counts,
.aic-complete__stale {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
}

.aic-complete__link {
  display: inline-block;
  margin-top: 4px;
}

.aic-msg__note--action {
  margin-top: 6px;
  font-style: normal;
}


.aic-typing {
  display: inline-flex;
  gap: 4px;
  padding: 10px 0;
}

.aic-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  animation: aic-blink 1.2s infinite ease-in-out;
}

.aic-typing span:nth-child(2) { animation-delay: .15s; }
.aic-typing span:nth-child(3) { animation-delay: .3s; }

@keyframes aic-blink {
  0%, 80%, 100% { opacity: .25; }
  40% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .aic-typing span { animation: none; opacity: .6; }
}

/* ------------------------------------------------------------ markdown */

.aic-md > :first-child { margin-top: 0; }
.aic-md > :last-child { margin-bottom: 0; }
.aic-md p { margin: 0 0 10px; }
.aic-md ul,
.aic-md ol { margin: 0 0 10px; padding-left: 22px; }
.aic-md li { margin: 2px 0; }
.aic-md .aic-md-h { margin: 16px 0 8px; line-height: 1.3; }
.aic-md h3 { font-size: 17px; }
.aic-md h4 { font-size: 15.5px; }
.aic-md h5,
.aic-md h6 { font-size: 14.5px; }
.aic-md a { color: var(--accent, #ff5a00); text-decoration: underline; }
.aic-md blockquote {
  margin: 0 0 10px;
  padding: 2px 0 2px 12px;
  border-left: 3px solid var(--border-hover, rgba(17, 17, 17, .2));
  color: var(--muted);
}
.aic-md hr { margin: 14px 0; border: 0; border-top: 1px solid var(--border); }
.aic-md-code {
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(17, 17, 17, .06);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .9em;
}
.aic-md-pre {
  position: relative;
  margin: 0 0 12px;
  padding: 14px 16px;
  border-radius: 10px;
  background: var(--panel-dark, #262626);
  color: #f2f2f2;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
}
.aic-md-pre code { white-space: pre; }
.aic-copy {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 3px 8px;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 6px;
  background: rgba(255, 255, 255, .08);
  color: #f2f2f2;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}
.aic-md-table { margin: 0 0 12px; overflow-x: auto; }
.aic-md-table table { border-collapse: collapse; font-size: 13.5px; }
.aic-md-table th,
.aic-md-table td { padding: 6px 10px; border: 1px solid var(--border); text-align: left; vertical-align: top; }
.aic-md-table th { background: var(--bg, #f4f5f7); }

/* ------------------------------------------------------------ settings page */

.aics-page { max-width: 1180px; }

.aics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.aics-card {
  border: 1px solid var(--border, #dde3ea);
  border-radius: 14px;
  background: var(--surface, #fff);
  box-shadow: 0 8px 24px rgba(31, 45, 68, .05);
  padding: 18px 20px;
  min-width: 0;
}

.aics-card--wide { margin-bottom: 18px; }

.aics-card h2 { margin: 0 0 4px; font-size: 17px; }

.aics-card__sub {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.aics-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 12px;
}

.aics-stat {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg, #f4f5f7);
}

.aics-stat dt { color: var(--muted); font-size: 11.5px; font-weight: 700; }
.aics-stat dd { margin: 3px 0 0; font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }

.aics-pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.aics-pill--off { background: #f1f1f1; color: #555; }
.aics-pill--test { background: #fff4d6; color: #7a5300; }
.aics-pill--on { background: #e3f4ea; color: #1f6b3e; }

.aics-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
}

.aics-field { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 700; }
.aics-field small { color: var(--muted); font-weight: 400; }

.aics-input,
.aics-select {
  padding: 8px 10px;
  border: 1px solid var(--border, #dde3ea);
  border-radius: 9px;
  background: var(--surface, #fff);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  min-width: 0;
}

.aics-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

.aics-status { font-size: 13px; color: var(--muted); }
.aics-status.is-error { color: #b42318; }
.aics-status.is-ok { color: #1f6b3e; }

.aics-table-wrap { overflow-x: auto; }

.aics-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.aics-table th,
.aics-table td {
  padding: 8px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.aics-table th { color: var(--muted); font-size: 11.5px; font-weight: 700; }
.aics-table .aics-input { width: 90px; }
.aics-model-name strong { display: block; }
.aics-model-name code { color: var(--muted); font-size: 11.5px; }
.aics-row-status { display: block; margin-top: 3px; font-size: 11.5px; white-space: normal; }

.aics-audit { margin: 0; padding: 0; list-style: none; font-size: 12.5px; }
.aics-audit li { padding: 7px 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.aics-audit time { color: var(--muted); margin-right: 8px; }

@media (max-width: 960px) {
  .aics-grid,
  .aics-form { grid-template-columns: minmax(0, 1fr); }
  .aics-stats { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

/* ------------------------------------------------------------ attachments (2B.3) */

.aic-main { position: relative; }

.aic-attach { order: -1; }
.aic-attach[hidden] { display: none; }

.aic-tray,
.aic-msg__files {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
}

.aic-tray[hidden] { display: none; }

.aic-msg__files {
  justify-content: flex-end;
  max-width: 85%;
  margin: 0 0 6px;
}

.aic-file {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 240px;
  max-width: 100%;
  min-height: 48px;
  padding: 6px 6px 6px 8px;
  border: 1px solid var(--border, #dde3ea);
  border-radius: 12px;
  background: var(--surface, #fff);
  box-sizing: border-box;
}

.aic-file--failed,
.aic-file--error {
  border-color: #f2b8b5;
  background: #fff6f5;
}

.aic-file__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--accent-soft, rgba(255, 90, 0, .08));
  color: var(--accent, #ff5a00);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .02em;
}

.aic-file__icon--pdf { background: #fdecea; color: #b42318; }
.aic-file__icon--xlsx,
.aic-file__icon--csv { background: #e8f5ee; color: #1a7f45; }
.aic-file__icon--docx { background: #e8f0fd; color: #1d4ed8; }
.aic-file__icon--pptx { background: #fff0e8; color: #b54708; }
.aic-file__icon--png,
.aic-file__icon--jpeg,
.aic-file__icon--webp { background: #f3e8ff; color: #7e22ce; }
.aic-file__icon--json { background: #edf2f7; color: #334155; font-size: 9px; }

.aic-artifacts { max-width: 85%; margin: 5px 0 9px; }
.aic-artifacts__label { margin: 0 0 5px; color: var(--muted); font-size: 11.5px; font-weight: 700; }
.aic-msg__files--artifacts { justify-content: flex-start; max-width: 100%; }
.aic-file--generated { width: min(330px, 100%); border-color: rgba(255, 90, 0, .26); }
.aic-file--expired { opacity: .72; background: var(--bg, #f4f5f7); }
.aic-file__thumb--generated { object-fit: cover; }
.aic-artifact-image {
  display: block;
  max-width: min(360px, 100%);
  margin: 0 0 8px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border, #dde3ea);
  border-radius: 12px;
  background: var(--bg, #f4f5f7);
  cursor: zoom-in;
}
.aic-artifact-image:focus-visible { outline: 2px solid var(--accent, #ff5a00); outline-offset: 2px; }
.aic-artifact-image__img { display: block; width: 100%; max-height: 320px; object-fit: contain; }

.aic-file__thumb {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--bg, #f4f5f7);
}

.aic-file__thumbbtn {
  display: inline-flex;
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: none;
  cursor: zoom-in;
}

.aic-file__thumbbtn:focus-visible { outline: 2px solid var(--accent, #ff5a00); outline-offset: 2px; }

.aic-file__text {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.aic-file__name {
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.aic-file__meta {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.35;
}

.aic-file--failed .aic-file__meta,
.aic-file--error .aic-file__meta { color: #b42318; white-space: normal; }

.aic-file__progress {
  display: block;
  height: 3px;
  overflow: hidden;
  border-radius: 2px;
  background: var(--border, #dde3ea);
}

.aic-file__progress > span {
  display: block;
  height: 100%;
  background: var(--accent, #ff5a00);
  transition: width .15s linear;
}

.aic-file__remove,
.aic-file__download { font-size: 16px; }

.aic-drop {
  position: absolute;
  inset: 8px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--accent, #ff5a00);
  border-radius: 16px;
  background: rgba(255, 255, 255, .9);
  pointer-events: none;
}

.aic-drop[hidden] { display: none; }
.aic-drop p { margin: 0; color: var(--accent, #ff5a00); font-size: 16px; font-weight: 700; }

.aic-viewer {
  max-width: min(96vw, 1100px);
  max-height: 92vh;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: var(--surface, #fff);
}

.aic-viewer::backdrop { background: rgba(17, 17, 17, .6); }

.aic-viewer__bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 14px;
  border-bottom: 1px solid var(--border, #dde3ea);
}

.aic-viewer__name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.aic-viewer__img {
  display: block;
  max-width: 100%;
  max-height: calc(92vh - 56px);
  margin: 0 auto;
  object-fit: contain;
}

.aics-form__heading { margin: 18px 0 2px; font-size: 14px; }

@media (max-width: 960px) {
  .aic-file { width: 100%; }
  .aic-msg__files { max-width: 92%; }
  .aic-artifacts { max-width: 92%; }
  .aic-attach,
  .aic-file__remove,
  .aic-file__download { width: 40px; height: 40px; }
  .aic-composer__hint.is-attention { display: block; flex-basis: 100%; order: 3; }
  .aic-composer__bar { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  .aic-file__progress > span { transition: none; }
}



/* ------------------------------------------------------------ web search (2B.4) */

.aic-web {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  order: -1;
  color: var(--muted);
  font-size: 12px;
}

.aic-web[hidden] { display: none; }
.aic-web__label { font-weight: 600; }

.aic-web__select {
  height: 30px;
  padding: 0 6px;
  border: 1px solid var(--border, #dde3ea);
  border-radius: 8px;
  background: var(--surface, #fff);
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
}

.aic-web-result { margin-top: 6px; }
.aic-web-result__line { margin: 0 0 4px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.aic-web-result__notice { margin: 2px 0; }
.aic-job { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--muted); font-size: 13.5px; }
.aic-job__cancel { margin-top: 8px; }
.aic-tier-badge { margin-left: 6px; }
.aic-basis { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.aic-basis__tag {
  padding: 2px 8px;
  border: 1px solid currentColor;
  border-radius: 999px;
  color: var(--muted);
  font-size: 11.5px;
}
.aic-basis__tag--verified { color: #166534; }
.aic-basis__tag--unsuccessful,
.aic-basis__tag--not_verified { color: #9a3412; }
.aic-files-used__partial { color: #9a3412; }
.aics-field--inline { flex-direction: row; align-items: center; gap: 8px; font-weight: 600; }

@media (max-width: 960px) {
  .aic-web__select { height: 40px; font-size: 16px; }
}

/* Web search mode is chosen automatically from the stored setting; the
   control itself is never shown (its value is still sent, see ai_chat.js). */
.aic-web,
.aic-web[hidden] { display: none !important; }

/* ------------------------------------------------------------ attachment strip */
/* Files staged in the composer: one compact row that scrolls sideways, so the
   composer keeps the same height for 1 or 10 files and the next card peeks in. */

.aic-tray {
  flex-wrap: nowrap;
  gap: 6px;
  max-width: 100%;
  margin: 0 0 6px;
  padding: 0 0 4px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.aic-tray .aic-file {
  flex: 0 0 156px;
  width: 156px;
  height: 46px;
  min-height: 0;
  padding: 4px 2px 4px 6px;
  gap: 6px;
  border-radius: 10px;
  scroll-snap-align: start;
}

.aic-tray .aic-file__icon,
.aic-tray .aic-file__thumb {
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  font-size: 9.5px;
}

.aic-tray .aic-file__name { font-size: 12.5px; }

.aic-tray .aic-file__meta,
.aic-tray .aic-file--failed .aic-file__meta,
.aic-tray .aic-file--error .aic-file__meta {
  overflow: hidden;
  font-size: 11px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.aic-tray .aic-file__remove {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  font-size: 15px;
}

@media (hover: none) {
  .aic-tray .aic-file__remove { width: 32px; height: 32px; }
}

/* ------------------------------------------------------------ AI Chat Usage (Phase 2D) */

.aicu-page { max-width: 1280px; }

.aicu-periods {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--border, rgba(17, 17, 17, .1));
  border-radius: 12px;
  background: var(--surface, #fff);
}

.aicu-period {
  min-width: 64px;
  padding: 7px 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.aicu-period[aria-pressed="true"] { background: #111; color: #fff; }
.aicu-period:focus-visible { outline: 2px solid var(--accent, #ff5a00); outline-offset: 2px; }

.aicu-range { margin: -6px 0 14px; color: var(--muted); font-size: 13px; }

.aicu-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
  margin: 0 0 10px;
}

.aicu-kpi {
  padding: 14px 16px;
  border: 1px solid var(--border, rgba(17, 17, 17, .1));
  border-radius: 14px;
  background: var(--surface, #fff);
  box-shadow: 0 8px 24px rgba(31, 45, 68, .04);
}

.aicu-kpi__label { margin: 0; color: var(--muted); font-size: 12px; font-weight: 700; }
.aicu-kpi__value { margin: 6px 0 0; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.aicu-kpi__hint { margin: 3px 0 0; color: var(--muted); font-size: 11.5px; }
.aicu-kpis--small .aicu-kpi__value { font-size: 18px; }

.aicu-note { margin: 6px 0 16px; color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.aicu-note.is-error { color: #b42318; }

.aicu-card { margin-bottom: 18px; }

.aicu-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.aicu-card__head h2 { margin: 0 0 4px; font-size: 17px; }
.aicu-search .aics-input { width: 240px; max-width: 100%; }

.aicu-table td,
.aicu-table th { white-space: nowrap; }
.aicu-num { text-align: right !important; font-variant-numeric: tabular-nums; }
.aicu-strong { font-weight: 700; }
.aicu-muted { color: var(--muted); }
.aicu-wrap { white-space: normal !important; min-width: 220px; }

.aicu-sort {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.aicu-sort.is-active { color: var(--text); }
th[aria-sort="descending"] .aicu-sort::after { content: " ↓"; }
th[aria-sort="ascending"] .aicu-sort::after { content: " ↑"; }

.aicu-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(17, 17, 17, .06);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.aicu-details { padding: 5px 12px; font-size: 12.5px; }

.aicu-pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
  font-size: 12.5px;
}

.aicu-empty { margin: 12px 0; color: var(--muted); font-size: 13px; }

.aicu-confirm {
  margin: 10px 0 14px;
  padding: 14px 16px;
  border: 1px solid var(--accent-border, rgba(255, 90, 0, .22));
  border-radius: 12px;
  background: var(--accent-soft, rgba(255, 90, 0, .08));
}

.aicu-confirm__notice { margin: 0 0 10px; font-size: 13px; line-height: 1.5; }
.aicu-subhead { margin: 18px 0 8px; font-size: 14px; }
.aicu-rhead { margin: 14px 0 6px; font-size: 13.5px; }
.aicu-list { margin: 0; padding-left: 20px; font-size: 13.5px; line-height: 1.55; }

.aicu-reports { margin: 0; padding: 0; list-style: none; font-size: 13px; }
.aicu-report-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }

.aicu-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent, #ff5a00);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

/* AI Analyse (2D.1): per-employee and consolidated reports. */
.aicu-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.aicu-summary { margin: 10px 0 4px; font-size: 14px; line-height: 1.55; }
.aicu-examples { display: block; margin-top: 3px; color: var(--muted); font-size: 12.5px; }
.aicu-convlinks { white-space: normal !important; min-width: 160px; }
.aicu-convlinks .aicu-link,
.aicu-convlinks .aicu-muted { display: block; max-width: 260px; overflow: hidden; font-size: 12.5px; text-align: left;
  text-overflow: ellipsis; white-space: nowrap; }
.aicu-person { margin: 6px 0; border: 1px solid var(--border, rgba(17, 17, 17, .1)); border-radius: 10px; }
.aicu-person__head { padding: 10px 12px; font-size: 13.5px; cursor: pointer; }
.aicu-person__body { padding: 0 12px 12px; }
.aicu-person[open] .aicu-person__head { border-bottom: 1px solid var(--border, rgba(17, 17, 17, .1)); margin-bottom: 8px; }

.aicu-back { margin-bottom: 12px; }
.aicu-detail__head { margin-bottom: 12px; }
.aicu-detail__name { margin: 0; font-size: 22px; }
.aicu-detail__email { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.aicu-viewer {
  width: min(860px, 96vw);
  max-height: 90vh;
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: var(--surface, #fff);
}

.aicu-viewer::backdrop { background: rgba(17, 17, 17, .45); }

.aicu-viewer__bar {
  position: sticky;
  top: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface, #fff);
}

.aicu-viewer__eyebrow { margin: 0; color: var(--muted); font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.aicu-viewer__title { margin: 2px 0 0; font-size: 16px; }

.aicu-transcript { margin: 0; padding: 12px 16px 18px; list-style: none; }
.aicu-msg { margin: 0 0 14px; padding: 10px 12px; border-radius: 12px; background: var(--bg, #f4f5f7); }
.aicu-msg--user { background: var(--accent-soft, rgba(255, 90, 0, .08)); }
.aicu-msg__head { margin: 0 0 6px; font-size: 12px; font-weight: 700; }
.aicu-msg__meta { color: var(--muted); font-size: 12px; font-weight: 400; }
.aicu-msg__body { font-size: 14px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.aicu-msg--assistant .aicu-msg__body { white-space: normal; }
.aicu-msg__file { margin: 6px 0 0; color: var(--muted); font-size: 12.5px; }
.aicu-msg__sources { margin: 6px 0 0; padding-left: 18px; color: var(--muted); font-size: 12.5px; }

@media (max-width: 720px) {
  .mp-page__actions { width: 100%; }
  .aicu-periods { width: 100%; }
  .aicu-period { flex: 1 1 0; min-width: 0; }
  .aicu-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .aicu-kpi__value { font-size: 18px; }
  .aicu-search .aics-input { width: 100%; }
  .aicu-actions { width: 100%; }
  .aicu-actions .mp-btn { flex: 1 1 auto; }
}
