/* IT AI — Sirius layout in IT-TUBE white-red. Fullscreen: site chrome hidden, only AI + back button. */
.ai-page .topbar, .ai-page .sidebar, .ai-page .bottombar { display: none !important; }
.ai-page .layout { max-width: none; padding: 0; display: block; }
.ai-page .content { padding: 0; }

.ai-app {
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: #ffffff;
  display: flex;
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  overflow: hidden;
}

/* Visible thin scrollbars inside AI (site hides them globally). */
.ai-list, .ai-msgs, .ai-composer textarea, .ai-doc pre, .ai-table-wrap {
  scrollbar-width: thin;
  scrollbar-color: #c9c9cf transparent;
}
.ai-list::-webkit-scrollbar, .ai-msgs::-webkit-scrollbar,
.ai-composer textarea::-webkit-scrollbar, .ai-doc pre::-webkit-scrollbar,
.ai-table-wrap::-webkit-scrollbar {
  display: block;
  width: 8px;
  height: 8px;
}
.ai-list::-webkit-scrollbar-thumb, .ai-msgs::-webkit-scrollbar-thumb,
.ai-composer textarea::-webkit-scrollbar-thumb, .ai-doc pre::-webkit-scrollbar-thumb,
.ai-table-wrap::-webkit-scrollbar-thumb {
  background: #c9c9cf;
  border-radius: 4px;
}
.ai-list::-webkit-scrollbar-track, .ai-msgs::-webkit-scrollbar-track,
.ai-composer textarea::-webkit-scrollbar-track, .ai-doc pre::-webkit-scrollbar-track,
.ai-table-wrap::-webkit-scrollbar-track {
  background: transparent;
}

/* ——— Sidebar ——— */
.ai-side {
  width: 280px;
  min-width: 280px;
  background: var(--bg-soft);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  transition: margin .22s ease;
}
.ai-app.collapsed .ai-side { margin-left: -280px; }
.ai-side-top { padding: 16px 14px 10px; border-bottom: 1px solid var(--border-soft); }
.ai-brand { font-weight: 800; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.ai-logo {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px; height: 24px; padding: 0 6px; border-radius: 6px;
  background: var(--red-bright); color: #fff; font-weight: 900; font-size: 13px;
}
.ai-search { margin-top: 10px; }
.ai-search input {
  width: 100%; padding: 8px 11px; border-radius: 8px;
  border: 1px solid var(--border); background: #fff; color: var(--text);
  outline: none; font-size: 13.5px;
}
.ai-search input::placeholder { color: var(--text-muted); }
.ai-search input:focus { border-color: var(--red-bright); }
.ai-new {
  width: 100%; margin-top: 10px; height: 38px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--red-bright); background: var(--red-bright); color: #fff;
  font-size: 14px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.ai-new:hover { background: var(--red-600); border-color: var(--red-600); }
.ai-side-label {
  padding: 12px 16px 6px; color: var(--text-muted); font-size: 11px;
  font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
}
.ai-list { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 2px 8px 12px; }
.ai-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 8px; cursor: pointer;
  color: var(--text-secondary); border: 1px solid transparent; font-size: 13.8px;
}
.ai-item:hover { background: #f1f2f4; color: var(--text); }
.ai-item.active { background: var(--red-soft); border-color: #f3b4b4; color: var(--text); }
.ai-item-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-item-rename {
  flex: 1; min-width: 0; border: 1px solid var(--red-bright); border-radius: 6px;
  padding: 4px 8px; font-size: 13.5px; outline: none; color: var(--text); background: #fff;
}
.ai-item-actions { opacity: 0; transition: opacity .12s; display: flex; gap: 2px; flex-shrink: 0; }
.ai-item:hover .ai-item-actions, .ai-item.active .ai-item-actions { opacity: 1; }
.ai-icon-btn {
  background: transparent; border: 0; color: var(--text-muted); cursor: pointer;
  font-size: 14px; padding: 5px 7px; border-radius: 6px; line-height: 1;
}
.ai-icon-btn:hover { color: var(--red-600); background: var(--red-soft); }
.ai-side-bottom { border-top: 1px solid var(--border-soft); padding: 12px 14px; }
.ai-user { display: flex; align-items: center; gap: 10px; font-size: 13.5px; font-weight: 600; }
.ai-ava {
  width: 30px; height: 30px; border-radius: 6px; flex: none;
  background: var(--red-bright); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px;
}
.ai-user span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-empty-hint { color: var(--text-muted); font-size: 13px; padding: 8px 10px; }

/* ——— Main ——— */
.ai-main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: #fff; }
.ai-top {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 16px; border-bottom: 1px solid var(--border-soft); flex-shrink: 0;
}
.ai-back {
  font-size: 13.5px; font-weight: 600; color: var(--text-secondary);
  padding: 7px 12px; border: 1px solid var(--border); border-radius: 8px;
  white-space: nowrap; flex-shrink: 0;
}
.ai-back:hover { color: var(--red-800); border-color: var(--red-bright); background: var(--red-ghost); text-decoration: none; }
.ai-top-title {
  font-weight: 600; font-size: 13px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; text-align: right;
}
.ai-burger { display: none; }
.ai-backdrop { display: none; }

/* ——— Hero ——— */
.ai-hero { text-align: center; margin: auto; padding: 24px; max-width: 620px; width: 100%; }
.ai-hero-logo {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 64px; height: 48px; padding: 0 14px; border-radius: 12px;
  background: var(--red-bright); color: #fff; font-weight: 900; font-size: 24px;
}
.ai-hero h1 { margin: 14px 0 4px; font-size: 32px; font-weight: 800; letter-spacing: -.5px; }
.ai-hero-sub { color: var(--text-muted); font-size: 15.5px; margin: 0 0 20px; }
.ai-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; text-align: left; }
.ai-sugg {
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  padding: 14px 16px; cursor: pointer; color: var(--text);
  transition: border-color .15s, transform .12s;
}
.ai-sugg:hover { border-color: var(--red-bright); transform: translateY(-1px); }
.ai-sugg h3 { margin: 0 0 4px; font-size: 14.5px; font-weight: 700; }
.ai-sugg p { margin: 0; font-size: 13px; color: var(--text-muted); }

/* ——— Messages ——— */
.ai-msgs {
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden;
  padding: 26px 22px 10px; max-width: 820px; width: 100%; margin: 0 auto;
  display: flex; flex-direction: column; gap: 14px;
}
.ai-msg { max-width: 100%; animation: ai-fade .22s ease; }
@keyframes ai-fade { from { opacity: 0; transform: translateY(5px); } }
.ai-msg-user {
  align-self: flex-end;
  background: var(--red-soft); border: 1px solid #f3b4b4;
  border-radius: 8px; padding: 9px 13px; max-width: 78%;
  font-size: 14.8px; line-height: 1.65; overflow-wrap: anywhere;
}
.ai-msg-ai { align-self: flex-start; width: 100%; }
.ai-doc { font-size: 15.2px; line-height: 1.75; color: var(--text); overflow-wrap: anywhere; min-width: 0; }
.ai-doc > *:first-child { margin-top: 0; }
.ai-doc p { margin: 0 0 10px; }
.ai-doc h1 { font-size: 21px; margin: 16px 0 8px; }
.ai-doc h2 { font-size: 18px; margin: 16px 0 8px; }
.ai-doc h3 { font-size: 16px; margin: 14px 0 8px; }
.ai-doc ul, .ai-doc ol { margin: 8px 0; padding-left: 22px; }
.ai-doc li { margin: 4px 0; }
.ai-doc a { color: var(--red-600); text-decoration: none; border-bottom: 1px solid #f3b4b4; }
.ai-doc a:hover { border-bottom-color: var(--red-bright); }
.ai-doc code.ic {
  background: var(--surface-2); border: 1px solid var(--border-soft);
  border-radius: 4px; padding: 1px 6px; font-size: 12.8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.ai-table-wrap { overflow-x: auto; margin: 10px 0; }
.ai-doc table { border-collapse: collapse; width: 100%; font-size: 14px; }
.ai-doc th, .ai-doc td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; vertical-align: top; }
.ai-doc th { background: var(--surface-2); }
.ai-doc blockquote { border-left: 2px solid var(--red-bright); margin: 10px 0; padding: 2px 12px; color: var(--text-secondary); }
.ai-doc hr { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }

/* Code blocks */
.ai-code { background: #1f2937; border-radius: 8px; overflow: hidden; margin: 12px 0; }
.ai-code-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 10px; border-bottom: 1px solid rgba(255,255,255,.12);
}
.ai-code-lang { color: #9ca3af; font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; }
.ai-copy {
  background: transparent; border: 1px solid #4b5563; color: #d1d5db;
  padding: 3px 9px; border-radius: 6px; font-size: 11.5px; cursor: pointer;
}
.ai-copy:hover { background: #374151; }
.ai-code pre { margin: 0; padding: 12px 14px; overflow-x: auto; font-size: 13px; line-height: 1.6; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: #f3f4f6; }
.ai-code code { font-family: inherit; }
.ai-doc .tok-k { color: #c084fc; } .ai-doc .tok-s { color: #86efac; }
.ai-doc .tok-n { color: #fbbf24; } .ai-doc .tok-f { color: #93c5fd; }

/* Math */
.ai-math-i { font-family: Georgia, "Times New Roman", serif; font-style: italic; padding: 0 2px; }
.ai-math-b {
  display: block; text-align: center; font-family: Georgia, "Times New Roman", serif;
  font-size: 17px; padding: 10px 8px; margin: 10px 0;
  background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: 8px; overflow-x: auto;
}
.ai-frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; margin: 0 3px; }
.ai-frac > span:first-child { border-bottom: 1px solid currentColor; padding: 0 6px; }
.ai-frac > span:last-child { padding: 0 6px; }

/* Content cards (IT-TUBE results) */
.ai-cards { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.ai-card {
  display: flex; align-items: stretch; text-align: left;
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  overflow: hidden; max-width: 520px; cursor: pointer; padding: 0; color: var(--text);
  transition: border-color .15s, transform .12s;
  font: inherit;
}
.ai-card:hover { border-color: var(--red-bright); transform: translateX(2px); }
.ai-card img { width: 120px; min-height: 84px; max-height: 120px; object-fit: cover; background: var(--surface-2); flex-shrink: 0; border: 0; }
.ai-card-body { padding: 10px 12px; flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 2px; }
.ai-card-body strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.ai-card-body span { font-size: 12.5px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-card-go { display: flex; align-items: center; padding: 0 12px; color: var(--red-600); font-size: 13px; font-weight: 600; flex-shrink: 0; }

/* Msg tools: copy + download */
.ai-msg-tools { opacity: 0; transition: opacity .12s; margin-top: 8px; display: flex; gap: 6px; }
.ai-msg-ai:hover .ai-msg-tools { opacity: 1; }
.ai-mini-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; padding: 0;
  background: transparent; border: 1px solid transparent; color: var(--text-muted);
  border-radius: 6px; cursor: pointer;
}
.ai-mini-btn svg { display: block; }
.ai-mini-btn:hover { border-color: var(--border); color: var(--text); background: var(--surface-2); }
.ai-mini-btn.copied { color: #16a34a; border-color: #bbf7d0; background: #f0fdf4; }

/* ——— Composer: only input, Enter to send ——— */
.ai-composer-wrap { padding: 10px 16px 14px; max-width: 820px; width: 100%; margin: 0 auto; flex-shrink: 0; }
.ai-typing { color: var(--text-muted); font-size: 12.5px; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.ai-typing[hidden] { display: none; }
.ai-typing .dot { display: inline-block; width: 5px; height: 5px; border-radius: 2px; background: var(--red-bright); animation: ai-blink 1s infinite; }
.ai-typing .dot:nth-child(2) { animation-delay: .15s; }
.ai-typing .dot:nth-child(3) { animation-delay: .3s; }
@keyframes ai-blink { 50% { opacity: .25; } }
.ai-composer {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 14px;
  transition: border-color .15s;
}
.ai-composer:focus-within { border-color: var(--red-bright); }
.ai-composer textarea {
  flex: 1; width: 100%; background: transparent; border: 0; outline: none; color: var(--text);
  resize: none; height: 40px; overflow-y: auto;
  font-size: 15px; line-height: 1.65;
}
.ai-composer textarea::placeholder { color: var(--text-muted); }

/* Error + toast */
.ai-error {
  background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c;
  padding: 10px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 16px;
}
.ai-error a { color: var(--red-600); font-weight: 600; }
.ai-toast {
  position: fixed; bottom: 22px; left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--text); color: #fff;
  padding: 9px 16px; border-radius: 8px; font-size: 13.5px;
  opacity: 0; transition: .22s; pointer-events: none; max-width: 90vw; z-index: 300;
}
.ai-toast.show { opacity: 1; transform: translateX(-50%); }

@media (max-width: 860px) {
  .ai-side {
    position: fixed; z-index: 120; height: 100dvh;
    transform: translateX(-100%); transition: transform .22s; margin-left: 0;
    border-right: 1px solid var(--border);
  }
  .ai-app.open .ai-side { transform: none; }
  .ai-app.collapsed .ai-side { transform: translateX(-100%); }
  .ai-burger { display: block; }
  .ai-collapse-btn { display: none; }
  .ai-backdrop {
    display: none; position: fixed; inset: 0; background: rgba(24,24,27,.45); z-index: 110;
  }
  .ai-app.open .ai-backdrop { display: block; }
  .ai-msg-user { max-width: 92%; }
  .ai-msgs { padding: 16px 14px 6px; }
  .ai-grid { grid-template-columns: minmax(0, 1fr); }
  .ai-hero h1 { font-size: 28px; }
}

/* Softer canvas, touch controls and safe-area support. */
.ai-side { background: #faf8f8; }
.ai-main { background: radial-gradient(ellipse at 55% 0,#fff3f3,transparent 55%),#fff; }
.ai-top { background: #ffffffd9; min-height: 64px; }
.ai-hero { max-height: 100%; overflow-y: auto; flex-shrink: 1; }
.ai-hero-logo { border-radius: 20px; width: 72px; height: 64px; box-shadow: 0 8px 30px #ef101025; }
.ai-hero h1 { letter-spacing: -1px; }
.ai-sugg { border-radius: 16px; padding: 18px; box-shadow: 0 4px 18px #18181b04; }
.ai-msgs { flex-basis: 0; }
.ai-msgs:empty { flex: 0; padding: 0; }
.ai-msg-user { border-radius: 20px 20px 5px 20px; }
.ai-composer { background: white; border-radius: 20px; box-shadow: 0 6px 30px #18181b09; }
.ai-composer textarea { min-width: 0; font-size: 16px; }
.ai-send { border: 0; background: var(--red-bright); color: white; width: 44px; height: 44px; border-radius: 14px; display: flex; justify-content: center; align-items: center; flex-shrink: 0; cursor: pointer; }
.ai-send:disabled { opacity: .45; cursor: wait; }
.ai-composer-note { font-size: 11px; color: var(--text-secondary); text-align: center; margin-top: 8px; }
.ai-composer-wrap { padding-bottom: max(14px, env(safe-area-inset-bottom)); }
.ai-icon-btn { min-width: 44px; min-height: 44px; }
.ai-msg-tools:focus-within, .ai-item:focus-within .ai-item-actions { opacity: 1; }
.ai-list::-webkit-scrollbar, .ai-msgs::-webkit-scrollbar, .ai-composer textarea::-webkit-scrollbar, .ai-doc pre::-webkit-scrollbar, .ai-table-wrap::-webkit-scrollbar { width: 8px !important; height: 8px !important; }
@media (hover:none) {
  .ai-item-actions, .ai-msg-tools { opacity: 1; }
  .ai-mini-btn { width: 40px; height: 40px; }
}
@media(max-width:860px) {
  .ai-side { width: min(280px,85vw); min-width: 0; }
  .ai-hero { padding: 16px; }
  .ai-hero h1 { font-size: 26px; }
  .ai-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .ai-sugg { padding: 12px; }
  .ai-sugg p { font-size: 12px; }
  .ai-composer-wrap { padding-left: 12px; padding-right: 12px; }
}
@media(max-height:580px) {
  .ai-hero-logo, .ai-hero-sub { display: none; }
  .ai-hero h1 { margin: 0 0 10px; font-size: 22px; }
}
