/* AI Tutor chat — v2: file uploads (chips, sent files, drop overlay) + visual refresh.
   Loaded after ai-chat.css (src/app/ai/chat/layout.tsx). */

/* ---- file-type badges (shared by chips, sent files, downloads) */
.cg-ftype { background: #525252; }
.cg-ftype--pdf { background: #dc2626; }
.cg-ftype--doc, .cg-ftype--docx { background: #2563eb; }
.cg-ftype--pptx, .cg-ftype--ppt { background: #ea580c; }
.cg-ftype--img { background: #0891b2; }
.cg-ftype--csv, .cg-ftype--tsv { background: #15803d; }
.cg-ftype--json, .cg-ftype--js, .cg-ftype--ts, .cg-ftype--py, .cg-ftype--html, .cg-ftype--css { background: #7c3aed; }

/* ---- welcome */
.cg-welcome { position: relative; isolation: isolate; }
.cg-orb {
  position: absolute; z-index: -1; left: 50%; top: 2vh; width: min(560px, 90vw); height: 260px; translate: -50% 0;
  background: radial-gradient(closest-side, rgba(139, 92, 246, .35), rgba(236, 72, 153, .16) 55%, transparent 75%);
  filter: blur(18px); animation: cg-float 9s ease-in-out infinite alternate; pointer-events: none;
}
@keyframes cg-float { to { transform: translate3d(0, 18px, 0) scale(1.06); } }
.cg-hello {
  display: inline-block; margin-bottom: 14px; padding: 5px 14px; border-radius: 999px; font-size: .85rem; font-weight: 500;
  color: #ddd6fe; background: rgba(139, 92, 246, .14); border: 1px solid rgba(167, 139, 250, .28);
}
.cg-welcome h1 { font-size: clamp(1.7rem, 4vw, 2.5rem); font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.cg-grad { background: linear-gradient(90deg, #a78bfa, #f472b6 55%, #fb923c); -webkit-background-clip: text; background-clip: text; color: transparent; }
.cg-app .cg-inline-link {
  background: none; border: 0; padding: 0; cursor: pointer; color: #c4b5fd; font: inherit; text-decoration: underline;
  text-decoration-color: rgba(196, 181, 253, .45); text-underline-offset: 3px;
}
.cg-app .cg-inline-link:hover { color: #ede9fe; }
.cg-card {
  position: relative; gap: 4px; padding: 16px; border-radius: 16px;
  background: linear-gradient(160deg, rgba(255, 255, 255, .045), rgba(255, 255, 255, .012));
  border: 1px solid rgba(255, 255, 255, .09);
  transition: transform .18s ease, border-color .18s ease, background .18s ease, box-shadow .18s ease;
  animation: cg-rise .45s ease both;
}
.cg-card:hover {
  transform: translateY(-3px); border-color: rgba(167, 139, 250, .45);
  background: linear-gradient(160deg, rgba(139, 92, 246, .14), rgba(255, 255, 255, .02));
  box-shadow: 0 10px 28px rgba(0, 0, 0, .35);
}
.cg-card-icon {
  display: grid; place-items: center; width: 36px; height: 36px; margin-bottom: 8px; border-radius: 11px;
  background: rgba(139, 92, 246, .16); color: #c4b5fd;
}
.cg-card .cg-card-icon i { margin: 0; color: inherit; font-size: .95rem; }
.cg-card:nth-child(2) .cg-card-icon { background: rgba(236, 72, 153, .15); color: #f9a8d4; }
.cg-card:nth-child(3) .cg-card-icon { background: rgba(14, 165, 233, .15); color: #7dd3fc; }
.cg-card:nth-child(4) .cg-card-icon { background: rgba(34, 197, 94, .14); color: #86efac; }
.cg-card:nth-child(5) .cg-card-icon { background: rgba(251, 146, 60, .15); color: #fdba74; }
.cg-card:nth-child(6) .cg-card-icon { background: rgba(250, 204, 21, .13); color: #fde047; }
@keyframes cg-rise { from { opacity: 0; transform: translateY(8px); } }

/* ---- messages appear smoothly */
.cg-msg { animation: cg-in .28s ease-out both; }
@keyframes cg-in { from { opacity: 0; transform: translateY(6px); } }
.cg-bubble { background: linear-gradient(180deg, #343434, #2d2d2d); border: 1px solid rgba(255, 255, 255, .06); }
.cg-ai-avatar { background: linear-gradient(135deg, rgba(139, 92, 246, .25), rgba(236, 72, 153, .2)); border-color: rgba(167, 139, 250, .35); color: #ddd6fe; }

/* ---- composer */
.cg-composer { border: 1px solid rgba(255, 255, 255, .08); transition: border-color .15s ease, box-shadow .2s ease; }
.cg-composer:focus-within { border-color: rgba(167, 139, 250, .55); box-shadow: 0 0 0 4px rgba(139, 92, 246, .12), 0 10px 30px rgba(0, 0, 0, .3); }
.cg-composer.has-files { padding-top: 10px; }
.cg-app .cg-send:not(:disabled):not(.cg-send--stop) { background: linear-gradient(135deg, #8b5cf6, #ec4899); color: #fff !important; box-shadow: 0 4px 14px rgba(139, 92, 246, .4); }
.cg-app .cg-send:not(:disabled):not(.cg-send--stop):hover { filter: brightness(1.1); }
.cg-send:not(:disabled) { transition: transform .12s ease, filter .12s ease; }
.cg-send:not(:disabled):active { transform: scale(.92); }

/* ---- attachment chips in the composer */
.cg-attach-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 4px 8px 0; max-height: 168px; overflow-y: auto; }
.cg-attach {
  position: relative; display: flex; align-items: center; gap: 10px; width: 228px; max-width: 100%; padding: 8px 30px 8px 8px;
  border-radius: 14px; background: #262626; border: 1px solid #3a3a3a; animation: cg-in .2s ease-out both;
}
.cg-attach .cg-ftype { width: 34px; height: 40px; font-size: .58rem; }
.cg-attach--reading { opacity: .85; }
.cg-attach--error { border-color: rgba(248, 113, 113, .55); background: rgba(127, 29, 29, .22); }
.cg-attach--error .cg-ftype { background: #b91c1c; }
.cg-attach--error small { color: #fca5a5 !important; white-space: normal !important; }
.cg-attach--img { width: 64px; height: 64px; padding: 0; overflow: hidden; }
.cg-attach--img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cg-attach-spin { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, .45); color: #fff; }
.cg-file-meta { min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.cg-file-meta b { font-weight: 500; font-size: .84rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cg-file-meta small { font-size: .74rem; color: var(--cg-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cg-app .cg-attach-x {
  position: absolute; top: 5px; right: 5px; width: 20px; height: 20px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center; font-size: .62rem; background: rgba(0, 0, 0, .55); color: #fff;
}
.cg-attach--img .cg-attach-x { top: 4px; right: 4px; }
.cg-app .cg-attach-x:hover { background: #ef4444; }

/* ---- files on a sent message */
.cg-msg--user { flex-direction: column; align-items: flex-end; gap: 8px; }
.cg-sent-files { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; max-width: min(80%, 560px); }
.cg-app .cg-sent-img { padding: 0; border: 1px solid rgba(255, 255, 255, .08); border-radius: 16px; overflow: hidden; cursor: zoom-in; background: #111; width: 132px; height: 132px; }
.cg-sent-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cg-file-card {
  display: flex; align-items: center; gap: 10px; width: 240px; max-width: 100%; padding: 10px 12px; border-radius: 14px;
  background: #2b2b2b; border: 1px solid #3a3a3a;
}
.cg-file-card .cg-ftype { width: 34px; height: 40px; font-size: .58rem; }

/* ---- "+" menu: upload item */
.cg-app .cg-create-menu { width: 270px; }
.cg-app .cg-create-menu .cg-menu-upload { align-items: center; gap: 12px; padding: 10px; }
.cg-menu-upload i { flex: none; width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: rgba(139, 92, 246, .18); color: #c4b5fd; }
.cg-menu-upload span { display: flex; flex-direction: column; line-height: 1.3; }
.cg-menu-upload b { font-weight: 600; }
.cg-menu-upload small { font-size: .74rem; color: var(--cg-faint); }
.cg-menu-sep { height: 1px; margin: 6px 4px; background: #3a3a3a; }

/* ---- drag-and-drop overlay */
.cg-main--drop .cg-composer { border-color: rgba(167, 139, 250, .7); }
.cg-drop {
  position: absolute; inset: 0; z-index: 30; display: grid; place-items: center; padding: 24px;
  background: rgba(17, 17, 17, .78); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); pointer-events: none;
  animation: cg-in .15s ease-out both;
}
.cg-drop-box {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 36px 48px; border-radius: 22px; text-align: center;
  border: 2px dashed rgba(167, 139, 250, .7); background: rgba(139, 92, 246, .08); color: var(--cg-text);
}
.cg-drop-box i { font-size: 2.2rem; color: #c4b5fd; margin-bottom: 4px; }
.cg-drop-box strong { font-size: 1.15rem; }
.cg-drop-box span { font-size: .86rem; color: var(--cg-muted); }

/* ---- sidebar touches */
.cg-conv.active { box-shadow: inset 3px 0 0 #a78bfa; }
.cg-new { border: 1px solid rgba(255, 255, 255, .08); }
.cg-new:hover { border-color: rgba(167, 139, 250, .4); }

/* ---- tablet */
@media (min-width: 561px) and (max-width: 900px) {
  .cg-thread { padding: 8px 24px 28px; }
  .cg-suggest { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cg-composer-wrap { padding: 0 16px 12px; }
}

/* ---- phone */
@media (max-width: 560px) {
  .cg-welcome { padding-top: 2vh; }
  .cg-hello { margin-bottom: 10px; font-size: .8rem; }
  .cg-welcome h1 { font-size: 1.55rem; }
  .cg-card { padding: 12px; border-radius: 14px; }
  .cg-card-icon { width: 30px; height: 30px; margin-bottom: 6px; border-radius: 9px; }
  .cg-card-title { font-size: .84rem; line-height: 1.3; }
  .cg-attach { width: calc(50% - 4px); }
  .cg-attach--img { width: 56px; height: 56px; }
  .cg-sent-files { max-width: 92%; }
  .cg-app .cg-sent-img { width: 104px; height: 104px; }
  .cg-file-card { width: 100%; }
  .cg-app .cg-create-menu { width: min(270px, calc(100vw - 32px)); }
  .cg-drop-box { padding: 26px 22px; }
}
/* ---- posters & videos made in the chat */
.cg-studio { margin: 14px 0; border: 1px solid #383838; border-radius: 18px; overflow: hidden; background: #1b1b1b; }
.cg-studio-pending { display: flex; align-items: center; gap: 10px; padding: 18px; color: var(--cg-muted); font-size: .9rem; }
.cg-studio-pending i { color: #c4b5fd; animation: cg-breathe 1.2s ease-in-out infinite; }
.cg-poster-frame { padding: 14px; background: #111; display: grid; place-items: center; }
.cg-poster-svg { width: 100%; max-width: 440px; height: auto; border-radius: 12px; box-shadow: 0 12px 34px rgba(0, 0, 0, .5); display: block; }
.cg-studio-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-top: 1px solid #2f2f2f; }
.cg-studio-title { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: .9rem; min-width: 0; }
.cg-studio-title i { color: #c4b5fd; }
.cg-studio-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.cg-app .cg-studio-actions button {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 10px; cursor: pointer;
  background: #2a2a2a; border: 1px solid #3a3a3a; color: var(--cg-text); font-size: .82rem; font-weight: 500;
}
.cg-app .cg-studio-actions button:hover:not(:disabled) { background: #333; border-color: #4a4a4a; }
.cg-app .cg-studio-actions button[aria-pressed="true"] { color: #c4b5fd; border-color: rgba(167, 139, 250, .5); }
.cg-app .cg-studio-actions .cg-studio-primary { background: linear-gradient(135deg, #8b5cf6, #ec4899); border-color: transparent; color: #fff; }
.cg-app .cg-studio-actions .cg-studio-primary:hover:not(:disabled) { filter: brightness(1.1); background: linear-gradient(135deg, #8b5cf6, #ec4899); }
.cg-studio-actions button:disabled { opacity: .55; cursor: progress; }
.cg-studio-status { flex-basis: 100%; font-size: .8rem; color: var(--cg-muted); }
.cg-video-canvas-wrap { position: relative; background: #000; }
.cg-video-canvas { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; }
.cg-app .cg-video-play {
  position: absolute; left: 50%; top: 50%; translate: -50% -50%; width: 74px; height: 74px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center; font-size: 1.6rem; color: #fff; background: rgba(0, 0, 0, .45);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); box-shadow: 0 0 0 2px rgba(255, 255, 255, .5); transition: transform .15s;
}
.cg-app .cg-video-play:hover { transform: scale(1.08); }
.cg-video-play i { margin-left: 4px; }

/* ---- mic, voice-mode button, dictation strip */
.cg-send-group { display: flex; align-items: center; gap: 6px; }
.cg-app .cg-mic {
  width: 36px; height: 36px; border-radius: 50%; border: 0; cursor: pointer; display: grid; place-items: center;
  background: none; color: var(--cg-muted); font-size: .95rem;
}
.cg-app .cg-mic:hover:not(:disabled) { background: #3a3a3a; color: var(--cg-text); }
.cg-app .cg-send.cg-voice-start { background: #ececec; color: #111 !important; box-shadow: none; }
.cg-app .cg-send.cg-voice-start:hover { background: #fff; }
.cg-dictate {
  display: flex; align-items: center; gap: 10px; margin: 2px 0 6px; padding: 8px 10px; border-radius: 14px;
  background: rgba(239, 68, 68, .08); border: 1px solid rgba(239, 68, 68, .25); font-size: .85rem; color: var(--cg-text);
}
.cg-rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #ef4444; animation: cg-blink 1s infinite; flex: none; }
.cg-rec-time { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 34px; }
.cg-rec-bars { display: flex; align-items: center; gap: 2px; height: 26px; flex: 0 1 140px; min-width: 60px; }
.cg-rec-bars i { flex: 1; min-width: 2px; border-radius: 2px; background: #f87171; transition: height .08s; }
.cg-rec-label { flex: 1; min-width: 0; color: var(--cg-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cg-app .cg-rec-btn { flex: none; width: 32px; height: 32px; border-radius: 50%; border: 0; cursor: pointer; display: grid; place-items: center; background: #333; color: #fff; }
.cg-app .cg-rec-btn:hover { background: #444; }
.cg-app .cg-rec-ok { background: #22c55e; color: #052e16; }
.cg-app .cg-rec-ok:hover { background: #4ade80; }
.cg-voice-error { display: flex; align-items: center; gap: 8px; margin: 2px 0 6px; padding: 8px 10px; border-radius: 12px; background: rgba(127, 29, 29, .25); color: #fecaca; font-size: .82rem; }
.cg-voice-error button { margin-left: auto; background: none; border: 0; color: inherit; cursor: pointer; }

/* ---- voice mode overlay */
.cg-voice {
  position: absolute; inset: 0; z-index: 40; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 24px;
  background: radial-gradient(circle at 50% 38%, #2e1065 0%, #171717 55%, #0d0d0d 100%); animation: cg-in .25s ease-out both;
}
.cg-voice-top { position: absolute; top: 18px; left: 0; right: 0; display: flex; justify-content: center; }
.cg-voice-badge { display: inline-flex; gap: 8px; align-items: center; padding: 6px 14px; border-radius: 999px; background: rgba(255, 255, 255, .08); color: #ddd6fe; font-size: .82rem; font-weight: 600; }
.cg-app .cg-voice-orb {
  position: relative; width: 190px; height: 190px; border-radius: 50%; border: 0; cursor: pointer; padding: 0;
  background: radial-gradient(circle at 35% 30%, #f0abfc, #a78bfa 40%, #6d28d9 75%);
  box-shadow: 0 0 60px rgba(167, 139, 250, .55), inset 0 -12px 30px rgba(46, 16, 101, .6); transition: transform .09s linear;
}
.cg-voice-core { position: absolute; inset: 22%; border-radius: 50%; background: radial-gradient(circle, rgba(255, 255, 255, .55), rgba(255, 255, 255, 0) 70%); }
.cg-voice-orb--thinking, .cg-voice-orb--transcribing, .cg-voice-orb--starting { animation: cg-orb-think 1.4s ease-in-out infinite; }
.cg-voice-orb--speaking { animation: cg-orb-speak .9s ease-in-out infinite; background: radial-gradient(circle at 35% 30%, #fbcfe8, #f472b6 40%, #be185d 78%); box-shadow: 0 0 70px rgba(244, 114, 182, .55); }
.cg-voice-orb--paused, .cg-voice-orb--error { filter: grayscale(.85) brightness(.7); box-shadow: none; }
@keyframes cg-orb-think { 50% { transform: scale(.92); filter: brightness(1.2); } }
@keyframes cg-orb-speak { 0%, 100% { transform: scale(1); } 30% { transform: scale(1.08); } 60% { transform: scale(.97); } }
.cg-voice-state { margin: 6px 0 0; font-size: 1.05rem; font-weight: 600; color: var(--cg-text); text-align: center; max-width: 520px; }
.cg-voice-captions { width: min(560px, 100%); display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.cg-voice-captions p { margin: 0; padding: 10px 14px; border-radius: 14px; font-size: .9rem; line-height: 1.5; color: var(--cg-text); background: rgba(255, 255, 255, .06); }
.cg-voice-captions b { display: block; font-size: .7rem; letter-spacing: .06em; text-transform: uppercase; color: var(--cg-faint); margin-bottom: 2px; }
.cg-voice-ai { border: 1px solid rgba(167, 139, 250, .25); }
.cg-voice-controls { display: flex; gap: 18px; margin-top: 8px; }
.cg-app .cg-voice-btn { width: 60px; height: 60px; border-radius: 50%; border: 0; cursor: pointer; display: grid; place-items: center; font-size: 1.3rem; background: #2f2f2f; color: #fff; }
.cg-app .cg-voice-btn:hover { background: #3a3a3a; }
.cg-app .cg-voice-btn.off { background: #fff; color: #111; }
.cg-app .cg-voice-end { background: #dc2626; }
.cg-app .cg-voice-end:hover { background: #ef4444; }
.cg-voice-hint { margin: 0; font-size: .78rem; color: var(--cg-faint); text-align: center; }

@media (max-width: 560px) {
  .cg-app .cg-voice-orb { width: 150px; height: 150px; }
  .cg-rec-label { display: none; }
  .cg-studio-actions { width: 100%; }
  .cg-app .cg-studio-actions button { flex: 1 1 auto; justify-content: center; }
}

/* ---- live voice (ChatGPT-style) */
.cg-live-dot { width: 8px; height: 8px; border-radius: 50%; background: #ef4444; box-shadow: 0 0 0 0 rgba(239, 68, 68, .6); animation: cg-live 1.6s infinite; }
@keyframes cg-live { 70% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); } 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); } }
.cg-voice-ring {
  position: absolute; inset: -18px; border-radius: 50%; pointer-events: none;
  border: 3px solid rgba(196, 181, 253, .55); transition: transform .08s linear, opacity .08s linear;
}
.cg-voice-orb--speaking .cg-voice-ring { border-color: rgba(249, 168, 212, .65); }
.cg-voice-orb--connecting, .cg-voice-orb--saving { animation: cg-orb-think 1.4s ease-in-out infinite; }
.cg-voice--live .cg-voice-orb--listening { transition: transform .06s linear; }
.cg-voice--live .cg-voice-orb--speaking { animation: none; transition: transform .06s linear; }
.cg-voice-notice { margin: 0; font-size: .82rem; color: #fde68a; text-align: center; max-width: 520px; }
.cg-voice-pair { display: flex; flex-direction: column; gap: 6px; }
.cg-voice-old { opacity: .5; }
.cg-voice-captions { max-height: 34vh; overflow-y: auto; scrollbar-width: thin; }
.cg-voice-voices { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; max-width: 560px; }
.cg-app .cg-voice-voices button {
  padding: 6px 12px; border-radius: 999px; cursor: pointer; font-size: .78rem;
  background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .12); color: var(--cg-muted);
}
.cg-app .cg-voice-voices button:hover:not(:disabled) { color: var(--cg-text); border-color: rgba(167, 139, 250, .5); }
.cg-app .cg-voice-voices button.on { background: rgba(139, 92, 246, .25); border-color: rgba(167, 139, 250, .7); color: #ede9fe; }
@media (max-width: 560px) {
  .cg-voice { gap: 12px; padding: 18px 14px; }
  .cg-voice-captions { max-height: 26vh; }
}

@media (prefers-reduced-motion: reduce) {
  .cg-orb, .cg-card, .cg-msg, .cg-attach, .cg-voice-orb, .cg-rec-dot, .cg-live-dot { animation: none; }
}
