/* ===========================================================================
   Aakhar Copilot — ChatGPT-style UI. Dark/glass, mobile-first.
   =========================================================================== */
:root {
  --bg: #0a0a0f;
  --bg-2: #0d0d16;
  --panel: #12121d;
  --panel-2: #171724;
  --surface: rgba(255,255,255,0.045);
  --border: rgba(255,255,255,0.09);
  --border-strong: rgba(255,255,255,0.16);
  --text: #f3f3fb;
  --text-dim: #a6a6bd;
  --text-faint: #6b6b80;
  --accent: #7c5cff;
  --accent-2: #21d4fd;
  --user: #2b2740;
  --danger: #ff6b6b;
  --ok: #3ddc97;
  --radius: 16px;
  --radius-sm: 11px;
  --font: "Inter", system-ui, -apple-system, sans-serif;
  --font-display: "Sora", var(--font);
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --side-w: 270px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.6; overflow: hidden; -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; color: inherit; }
::selection { background: rgba(124,92,255,0.4); }

.aurora { position: fixed; inset: 0; z-index: -2; overflow: hidden; background: radial-gradient(1000px 600px at 75% -10%, #18122e 0%, transparent 60%), linear-gradient(180deg, var(--bg), var(--bg-2)); }
.aurora__blob { position: absolute; border-radius: 50%; filter: blur(100px); opacity: 0.4; }
.aurora__blob--1 { width: 40vw; height: 40vw; background: radial-gradient(circle, var(--accent), transparent 70%); top: -12vw; right: -6vw; }
.aurora__blob--2 { width: 34vw; height: 34vw; background: radial-gradient(circle, var(--accent-2), transparent 70%); bottom: -14vw; left: -8vw; opacity: 0.25; }

.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid rgba(255,255,255,0.18); border-top-color: #fff; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-center { display: grid; place-items: center; min-height: 100dvh; }

.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand__mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #0a0a0f; }
.brand__name { font-family: var(--font-display); font-weight: 700; font-size: 16px; }
.brand__name span { color: var(--text-dim); font-weight: 500; }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login__card { width: min(400px,100%); padding: 34px 30px 28px; border: 1px solid var(--border); border-radius: var(--radius); background: linear-gradient(160deg, var(--panel-2), var(--panel)); box-shadow: 0 30px 80px -30px #000; animation: rise .5s cubic-bezier(.16,1,.3,1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.login__brand { display: flex; flex-direction: column; align-items: center; gap: 13px; text-align: center; margin-bottom: 22px; }
.login__brand .brand__mark { width: 52px; height: 52px; border-radius: 15px; }
.login__title { font-family: var(--font-display); font-size: 1.35rem; font-weight: 700; }
.login__sub { color: var(--text-dim); font-size: .9rem; margin-top: 3px; }
.field { margin-bottom: 13px; }
.field label { display: block; font-size: 12.5px; color: var(--text-dim); margin-bottom: 6px; }
.input { width: 100%; padding: 12px 14px; border-radius: var(--radius-sm); background: rgba(255,255,255,.04); border: 1px solid var(--border); color: var(--text); outline: none; transition: border-color .2s, box-shadow .2s; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(124,92,255,.14); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 20px; border-radius: 999px; font-size: 14.5px; font-weight: 600; cursor: pointer; border: 1px solid transparent; transition: transform .2s, box-shadow .2s, background .2s, border-color .2s; -webkit-tap-highlight-color: transparent; }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn--primary { color: #0a0a0f; background: linear-gradient(135deg,#fff,#d9d4ff); box-shadow: 0 14px 40px -16px rgba(124,92,255,.8); }
.btn--primary:not(:disabled):hover { transform: translateY(-2px); }
.btn--block { width: 100%; }
.login__error { display: flex; gap: 9px; margin-bottom: 13px; padding: 11px 14px; border-radius: var(--radius-sm); background: rgba(255,107,107,.1); border: 1px solid rgba(255,107,107,.3); color: #ffc9c9; font-size: 13.5px; }
.login__foot { margin-top: 16px; text-align: center; color: var(--text-faint); font-size: 12px; }

/* ---------- app shell ---------- */
.app { display: grid; grid-template-columns: var(--side-w) 1fr; height: 100dvh; }

.sidebar { display: flex; flex-direction: column; border-right: 1px solid var(--border); background: rgba(10,10,16,.6); backdrop-filter: blur(8px); min-height: 0; }
.sidebar__head { display: flex; align-items: center; justify-content: space-between; padding: 16px 14px; }
.newchat { display: flex; align-items: center; gap: 9px; width: 100%; margin: 0 14px 10px; width: calc(100% - 28px); padding: 11px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer; font-weight: 500; font-size: 14px; transition: border-color .2s, background .2s; }
.newchat:hover { border-color: var(--accent); background: rgba(124,92,255,.08); }
.sessions { flex: 1; overflow-y: auto; padding: 4px 10px 16px; display: flex; flex-direction: column; gap: 2px; }
.sess { display: flex; align-items: center; gap: 8px; padding: 10px 11px; border-radius: 10px; cursor: pointer; color: var(--text-dim); border: 1px solid transparent; }
.sess:hover { background: var(--surface); color: var(--text); }
.sess--active { background: var(--panel-2); color: var(--text); border-color: var(--border); }
.sess__title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13.5px; }
.sess__act { opacity: 0; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; background: none; border: none; color: var(--text-faint); cursor: pointer; flex-shrink: 0; }
.sess:hover .sess__act, .sess--active .sess__act { opacity: 1; }
.sess__act:hover { color: var(--text); background: rgba(255,255,255,.07); }
.sess__act--danger:hover { color: #ffc9c9; background: rgba(255,107,107,.12); }
.sidebar__foot { padding: 12px 14px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.sidebar__user { font-size: 12.5px; color: var(--text-faint); font-family: var(--mono); }
.iconbtn { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; cursor: pointer; background: none; border: 1px solid var(--border); color: var(--text-dim); transition: color .2s, border-color .2s; }
.iconbtn:hover { color: var(--text); border-color: var(--border-strong); }

/* ---------- chat area ---------- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.topbar { display: none; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.topbar__title { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.thread { flex: 1; overflow-y: auto; scroll-behavior: smooth; }
.thread__inner { max-width: 800px; margin: 0 auto; padding: 28px 20px 24px; }

.empty { display: grid; place-items: center; min-height: 60dvh; text-align: center; padding: 24px; }
.empty__mark { width: 60px; height: 60px; border-radius: 18px; display: grid; place-items: center; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #0a0a0f; margin-bottom: 20px; }
.empty h1 { font-family: var(--font-display); font-weight: 700; font-size: 1.6rem; margin-bottom: 8px; }
.empty p { color: var(--text-dim); max-width: 42ch; }
.suggest { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 22px; }
.suggest button { padding: 10px 15px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-dim); cursor: pointer; font-size: 13.5px; transition: all .2s; }
.suggest button:hover { color: var(--text); border-color: var(--accent); }

.msg { display: flex; gap: 14px; padding: 18px 0; }
.msg__avatar { flex-shrink: 0; width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; font-size: 13px; font-weight: 700; }
.msg--user .msg__avatar { background: var(--user); color: #cdb8ff; }
.msg--assistant .msg__avatar { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #0a0a0f; }
.msg__body { min-width: 0; flex: 1; padding-top: 3px; }
.msg__role { font-size: 12px; font-weight: 600; color: var(--text-faint); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .06em; }
.md { font-size: 15.5px; line-height: 1.7; word-wrap: break-word; overflow-wrap: anywhere; }
.md > *:first-child { margin-top: 0; }
.md > *:last-child { margin-bottom: 0; }
.md p { margin: 0 0 12px; }
.md h1, .md h2, .md h3 { font-family: var(--font-display); margin: 18px 0 10px; line-height: 1.3; }
.md h1 { font-size: 1.4rem; } .md h2 { font-size: 1.2rem; } .md h3 { font-size: 1.05rem; }
.md ul, .md ol { margin: 0 0 12px; padding-left: 22px; }
.md li { margin: 4px 0; }
.md a { color: var(--accent-2); text-decoration: underline; }
.md strong { color: #fff; font-weight: 650; }
.md code { font-family: var(--mono); font-size: .9em; background: rgba(255,255,255,.08); padding: 2px 6px; border-radius: 6px; }
.md pre { margin: 0 0 14px; background: #07070d; border: 1px solid var(--border); border-radius: 12px; overflow-x: auto; }
.md pre code { display: block; padding: 14px 16px; background: none; border-radius: 0; font-size: 13.5px; line-height: 1.55; }
.md blockquote { border-left: 3px solid var(--accent); padding-left: 14px; color: var(--text-dim); margin: 0 0 12px; }
.md table { border-collapse: collapse; margin: 0 0 14px; font-size: 14px; display: block; max-width: 100%; overflow-x: auto; }
.md thead { background: rgba(255,255,255,.05); }
.md th, .md td { border: 1px solid var(--border); padding: 7px 11px; text-align: left; }
.md th { font-weight: 600; color: #fff; }
.md hr { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
.md img { max-width: 100%; border-radius: 8px; }
.md em { font-style: italic; }
.md del { opacity: .65; }
.cursor-blink::after { content: "▍"; color: var(--accent); animation: blink 1s steps(2) infinite; margin-left: 1px; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- agent activity (behind-the-scenes trail) ---------- */
.activity { margin: 0 0 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: rgba(255,255,255,.025); overflow: hidden; }
.activity__head { display: flex; align-items: center; gap: 8px; width: 100%; padding: 9px 12px; background: none; border: none; cursor: pointer; color: var(--text-dim); font-size: 13px; text-align: left; }
.activity__head:hover { color: var(--text); }
.activity__caret { display: inline-block; transition: transform .18s; font-size: 11px; color: var(--text-faint); }
.activity__caret--open { transform: rotate(90deg); }
.activity__list { border-top: 1px solid var(--border); padding: 6px 0; }
.activity__step { display: flex; align-items: baseline; gap: 9px; padding: 5px 12px; font-size: 12.5px; }
.activity__icon { flex-shrink: 0; width: 14px; text-align: center; color: var(--ok); font-weight: 700; }
.activity__step--fail .activity__icon { color: var(--danger); }
.activity__tool { flex-shrink: 0; color: var(--accent-2); font-family: var(--mono); font-size: 11.5px; padding: 1px 6px; border-radius: 5px; background: rgba(33,212,253,.1); }
.activity__text { min-width: 0; color: var(--text-dim); font-family: var(--mono); font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; background: none; padding: 0; }
.msg__err { color: #ffc9c9; background: rgba(255,107,107,.1); border: 1px solid rgba(255,107,107,.3); padding: 11px 14px; border-radius: var(--radius-sm); font-size: 14px; }

/* ---------- composer ---------- */
.composer { padding: 12px 20px 18px; }
.composer__inner { max-width: 800px; margin: 0 auto; }
.composer__box { display: flex; align-items: flex-end; gap: 10px; padding: 10px 10px 10px 16px; border: 1px solid var(--border-strong); border-radius: 18px; background: var(--panel-2); transition: border-color .2s, box-shadow .2s; }
.composer__box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(124,92,255,.12); }
.composer textarea { flex: 1; resize: none; border: none; background: none; outline: none; font-size: 15px; line-height: 1.5; max-height: 200px; padding: 6px 0; }
.composer textarea::placeholder { color: var(--text-faint); }
.send { flex-shrink: 0; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; border: none; cursor: pointer; background: linear-gradient(135deg,#fff,#d9d4ff); color: #0a0a0f; transition: transform .15s, opacity .2s; }
.send:disabled { opacity: .4; cursor: not-allowed; }
.send:not(:disabled):hover { transform: scale(1.06); }
.composer__hint { text-align: center; color: var(--text-faint); font-size: 11.5px; margin-top: 8px; }

/* ---------- mobile ---------- */
.scrim { display: none; }
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 84vw; max-width: 320px; z-index: 40; transform: translateX(-100%); transition: transform .25s ease; }
  .sidebar--open { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 35; opacity: 0; pointer-events: none; transition: opacity .25s; }
  .scrim--show { opacity: 1; pointer-events: auto; }
  .topbar { display: flex; }
  .thread__inner, .composer__inner { max-width: 100%; }
}

/* ---------- voice ---------- */
.iconbtn--active { color: var(--accent); border-color: var(--accent); background: rgba(124,92,255,.12); }
.iconbtn--active:hover { color: var(--accent); }
.mic-btn { flex-shrink: 0; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--border); background: none; color: var(--text-dim); cursor: pointer; transition: color .2s, border-color .2s, background .2s; }
.mic-btn:hover { color: var(--text); border-color: var(--border-strong); }
.mic-btn--on { color: var(--danger); border-color: var(--danger); background: rgba(255,107,107,.1); animation: mic-pulse 1.5s ease-in-out infinite; }
.mic-btn:disabled { opacity: .4; cursor: not-allowed; animation: none; }
@keyframes mic-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255,107,107,.5); } 60% { box-shadow: 0 0 0 7px rgba(255,107,107,0); } }
.converse-hint { color: var(--accent); font-size: 11.5px; }
