/* Academic As — Agent View */

.agent-shell { display: grid; gap: 16px; animation: page-in 340ms var(--ease-liquid); }
.agent-mobile-back, .agent-mobile-pending { display: none; }

/* Agent hero */
.agent-hero {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 18px;
  min-height: 154px; padding: 25px 26px; border-radius: 30px;
  box-shadow: 0 28px 70px rgb(0 0 0 / 13%), inset 0 1px rgb(255 255 255 / 13%);
}
.agent-hero::before { content: ""; position: absolute; inset: -80% 25% auto -5%; height: 260px; border-radius: 50%; background: radial-gradient(circle, rgb(110 92 255 / 22%), transparent 69%); pointer-events: none; }
.agent-hero h1 { margin: 0; font-size: clamp(29px,4vw,44px); line-height: 1; letter-spacing: -.035em; }
.agent-hero p:not(.eyebrow) { max-width: 650px; margin: 8px 0 0; color: var(--ink-soft); font-size: 13px; }

/* Agent orb */
.agent-orb {
  position: relative; isolation: isolate;
  display: grid; place-items: center;
  width: 82px; height: 82px;
  border: 1px solid rgb(255 255 255 / 28%); border-radius: 29px;
  background: linear-gradient(145deg, rgb(255 255 255 / 18%), rgb(110 92 255 / 15%));
  box-shadow: inset 0 1px rgb(255 255 255 / 35%), 0 16px 38px rgb(33 19 91 / 23%);
  animation: crystal-agent-float 4.8s ease-in-out infinite;
}
@keyframes crystal-agent-float { 0%,100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-6px) rotate(2deg); } }
.agent-orb::before, .agent-orb > span { content: ""; position: absolute; border-radius: 50%; }
.agent-orb::before { z-index: -1; width: 56px; height: 56px; background: conic-gradient(from 180deg, var(--cyan), var(--violet), #c36fff, var(--cyan)); filter: blur(1px); animation: agent-orbit 8s linear infinite; }
.agent-orb::after { content: ""; position: absolute; inset: -10px; z-index: -2; border: 1px solid rgb(105 119 255 / 18%); border-radius: 35px; animation: crystal-agent-halo 3.8s ease-out infinite; }
@keyframes crystal-agent-halo { 0% { transform: scale(.86); opacity: .55; } 80%,100% { transform: scale(1.18); opacity: 0; } }
.agent-orb > span { width: 45px; height: 45px; border: 1px solid rgb(255 255 255 / 35%); background: rgb(14 18 33 / 68%); box-shadow: inset 0 5px 15px rgb(255 255 255 / 10%); }
.agent-orb > img { z-index: 1; width: 38px; height: 38px; object-fit: contain; filter: drop-shadow(0 0 7px var(--cyan)); position: relative; }

.agent-hero-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; max-width: 420px; }
.agent-hero-actions button svg { width: 16px; }
.agent-provider { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink-faint); background: rgb(255 255 255 / 5%); font-size: 9px; font-weight: 750; }
.agent-provider svg { width: 12px; }
.agent-provider.is-ready { color: var(--success); }
.agent-provider.is-fallback { color: var(--warning); }

/* Control panel */
.agent-control {
  display: grid; grid-template-columns: minmax(240px,1fr) minmax(260px,.7fr) minmax(280px,1fr);
  align-items: center; gap: 16px; padding: 15px 18px; border-radius: 22px;
  animation: reveal 180ms var(--ease-liquid);
}
.agent-control > div, .agent-control > label { display: flex; align-items: center; gap: 10px; }
.agent-control > div > svg { width: 20px; color: var(--violet-soft); }
.agent-control span { display: grid; }
.agent-control strong { font-size: 12px; }
.agent-control small { margin-top: 2px; color: var(--ink-faint); font-size: 9px; }
.agent-control select { min-height: 40px; padding: 0 35px 0 12px; border: 1px solid var(--line); border-radius: 13px; color: var(--ink); background: var(--surface-solid); font-size: 11px; font-weight: 700; }
.agent-control > label { justify-content: space-between; padding-left: 16px; border-left: 1px solid var(--line); cursor: pointer; }

/* Workspace */
.agent-workspace { display: grid; grid-template-columns: minmax(0,1.7fr) minmax(285px,.7fr); gap: 16px; min-height: 650px; }
.agent-conversation { overflow: hidden; display: grid; grid-template-rows: minmax(0,1fr) auto; min-width: 0; min-height: 650px; border-radius: 28px; }
.agent-messages {
  min-height: 0; max-height: calc(100dvh - 340px); overflow-y: auto;
  display: flex; flex-direction: column; gap: 17px; padding: 24px;
  scrollbar-color: rgb(110 92 255 / 35%) transparent;
}

/* Welcome state */
.agent-welcome { display: grid; place-items: center; align-content: center; flex: 1; min-height: 430px; text-align: center; }
.agent-welcome > span {
  display: grid; place-items: center; width: 64px; height: 64px; margin-bottom: 17px;
  border: 1px solid rgb(255 255 255 / 20%); border-radius: 23px; overflow: hidden;
  box-shadow: 0 15px 42px rgb(75 52 211 / 29%), inset 0 1px rgb(255 255 255 / 38%);
  animation: crystal-breathe 5.2s ease-in-out infinite;
}
.agent-welcome > span img { width: 100%; height: 100%; object-fit: contain; }
.agent-welcome h2 { margin: 0; font-size: 23px; }
.agent-welcome > p { max-width: 430px; margin: 7px auto 20px; color: var(--ink-faint); font-size: 12px; line-height: 1.55; }
.agent-welcome > div { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 650px; }
.agent-welcome button { padding: 9px 12px; border: 1px solid var(--line); border-radius: 13px; color: var(--ink-soft); background: rgb(255 255 255 / 5%); font-size: 10px; cursor: pointer; transition: 160ms ease; }
.agent-welcome button:hover { color: var(--ink); border-color: rgb(110 92 255 / 35%); background: rgb(110 92 255 / 10%); transform: translateY(-1px); }

/* Messages */
.agent-message { display: flex; align-items: flex-start; gap: 10px; max-width: 86%; animation: message-in 210ms var(--ease-liquid); }
.agent-message.is-user { align-self: flex-end; justify-content: flex-end; }
.agent-message > div { padding: 13px 15px; border: 1px solid var(--line); border-radius: 18px 18px 18px 6px; background: rgb(255 255 255 / 5%); box-shadow: inset 0 1px rgb(255 255 255 / 6%); }
.agent-message.is-user > div { border-radius: 18px 18px 6px 18px; border-color: rgb(110 92 255 / 20%); background: linear-gradient(135deg, rgb(110 92 255 / 18%), rgb(47 181 224 / 9%)); }
.agent-message small { display: block; margin-bottom: 5px; color: var(--violet-soft); font-size: 8px; font-weight: 850; letter-spacing: .08em; }
.agent-message.is-user small { color: var(--cyan); text-align: right; }
.agent-message p { margin: 0; color: var(--ink-soft); font-size: 13px; line-height: 1.58; white-space: pre-wrap; }
.agent-message.is-streaming p::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 1em;
  margin-left: 4px;
  border-radius: 999px;
  vertical-align: -2px;
  background: linear-gradient(var(--cyan), var(--violet-soft));
  animation: stream-caret 850ms ease-in-out infinite;
}
@keyframes stream-caret { 50% { opacity: .2; } }
.agent-message em { display: block; margin-top: 8px; color: var(--warning); font-size: 9px; font-style: normal; }
/* Markdown in agent messages */
.agent-message h1, .agent-message h2, .agent-message h3 { color: var(--ink); }
.agent-message h2 { font-size: 15px; margin: 12px 0 5px; }
.agent-message h3 { font-size: 13px; margin: 8px 0 4px; }
.agent-message ul, .agent-message ol { margin: 6px 0; padding-left: 18px; }
.agent-message li { font-size: 13px; line-height: 1.55; color: var(--ink-soft); }
.agent-message code { font-family: monospace; font-size: 11px; background: rgb(110 92 255 / 10%); padding: 1px 5px; border-radius: 5px; color: var(--violet-soft); }
.agent-message pre { background: rgb(0 0 0 / 25%); border-radius: 10px; padding: 11px; overflow-x: auto; }
.agent-message pre code { background: transparent; padding: 0; font-size: 11px; color: var(--ink-soft); }
.agent-message table { width: 100%; border-collapse: collapse; font-size: 11px; overflow-x: auto; display: block; }
.agent-message th { padding: 7px 10px; border-bottom: 1px solid var(--line-strong); color: var(--ink-faint); text-align: left; font-size: 9px; text-transform: uppercase; }
.agent-message td { padding: 7px 10px; border-bottom: 1px solid var(--line); color: var(--ink-soft); }
.agent-message a { color: var(--cyan); }

.agent-avatar { flex: 0 0 auto; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 11px; overflow: hidden; box-shadow: inset 0 1px rgb(255 255 255 / 30%); }
.agent-avatar img { width: 100%; height: 100%; object-fit: contain; }

/* Thinking indicator */
.agent-message.is-thinking p { display: flex; gap: 4px; min-width: 40px; padding: 6px 2px; }
.agent-message.is-thinking i { width: 5px; height: 5px; border-radius: 50%; background: var(--violet-soft); animation: thinking 1.15s ease-in-out infinite; }
.agent-message.is-thinking i:nth-child(2) { animation-delay: 140ms; }
.agent-message.is-thinking i:nth-child(3) { animation-delay: 280ms; }

/* Composer */
.agent-composer { position: relative; display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 10px; padding: 13px; border-top: 1px solid var(--line); background: rgb(8 11 20 / 18%); }
.agent-composer textarea { resize: none; width: 100%; min-height: 56px; max-height: 160px; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: 16px; outline: none; color: var(--ink); background: rgb(255 255 255 / 5%); font-size: 12px; line-height: 1.45; }
.agent-composer textarea:focus { border-color: rgb(110 92 255 / 48%); box-shadow: 0 0 0 3px rgb(110 92 255 / 9%); }
.agent-composer > button.send-btn { width: 48px; height: 48px; border-radius: 16px !important; }
.agent-composer > button svg { width: 18px; }
.agent-composer-actions { display: flex; align-items: center; gap: 5px; }
.agent-composer footer { grid-column: 1 / -1; display: flex; align-items: center; gap: 5px; padding: 0 4px; color: var(--ink-faint); font-size: 9px; }
.agent-composer footer svg { width: 11px; }

/* Mobile composer */
.agent-mobile-bar {
  position: sticky; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: auto 1fr auto auto; align-items: end; gap: 8px;
  padding: 10px 12px max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line-strong);
  background: color-mix(in srgb, var(--surface-solid) 88%, transparent);
  -webkit-backdrop-filter: blur(20px) saturate(140%); backdrop-filter: blur(20px) saturate(140%);
}
.agent-mobile-bar textarea { min-height: 44px; max-height: 120px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 14px; color: var(--ink); background: rgb(255 255 255 / 5%); font-size: 14px; resize: none; outline: none; }
.agent-mobile-bar button { display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 14px; color: var(--ink-soft); background: rgb(255 255 255 / 5%); }
.agent-mobile-bar button svg { width: 20px; }
.agent-mobile-bar button.send-btn { background: linear-gradient(135deg, #7968ff, #5f5cf6); border-color: rgb(255 255 255 / 20%); color: white; }
.agent-mobile-bar button.is-listening { color: var(--danger); border-color: rgb(255 101 115 / 30%); background: rgb(255 101 115 / 10%); }

/* Sidebar panels */
.agent-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.agent-actions, .agent-history, .agent-signals, .agent-document { overflow: hidden; border-radius: 24px; transition: border-color .28s ease; }

.agent-signals { padding: 14px; }
.agent-signals > header, .agent-document > header { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 9px; padding: 2px 2px 11px; }
.agent-signals > header > svg, .agent-document > header > svg { width: 17px; color: var(--violet-soft); }
.agent-signals header > div, .agent-document header > div { display: grid; min-width: 0; }
.agent-signals header strong, .agent-document header strong { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.agent-signals header small, .agent-document header small { margin-top: 2px; color: var(--ink-faint); font-size: 8px; }
.agent-signals header button { border: 0; color: var(--violet-soft); background: transparent; font-size: 8px; font-weight: 750; cursor: pointer; }
.agent-signals article { display: grid; grid-template-columns: auto 1fr; gap: 8px; padding: 9px 7px; border-top: 1px solid var(--line); }
.agent-signals article > span { width: 6px; height: 6px; margin-top: 4px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 8px currentColor; }
.agent-signals article.signal-important > span { background: var(--warning); }
.agent-signals article.signal-critical > span { background: var(--danger); }
.agent-signals article div { min-width: 0; }
.agent-signals article strong { display: block; font-size: 9px; }
.agent-signals article p { margin: 3px 0 0; color: var(--ink-faint); font-size: 8px; line-height: 1.42; }

.agent-actions { min-height: 310px; padding: 16px; }
.agent-actions > header { display: flex; align-items: center; gap: 10px; padding: 2px 2px 14px; }
.agent-actions > header > span { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 12px; color: var(--violet-soft); background: rgb(110 92 255 / 12%); }
.agent-actions > header svg { width: 17px; }
.agent-actions > header > div { display: grid; }
.agent-actions header strong { font-size: 12px; }
.agent-actions header small { margin-top: 2px; color: var(--ink-faint); font-size: 9px; }
.agent-side-empty { min-height: 215px; display: grid; place-items: center; align-content: center; gap: 10px; color: var(--ink-faint); text-align: center; font-size: 10px; }
.agent-side-empty svg { width: 35px; height: 35px; padding: 9px; border-radius: 13px; color: var(--success); background: rgb(45 211 128 / 10%); }

.agent-action-card { display: grid; gap: 9px; margin-top: 8px; padding: 13px; border: 1px solid rgb(110 92 255 / 24%); border-radius: 17px; background: linear-gradient(145deg, rgb(110 92 255 / 10%), rgb(255 255 255 / 3%)); }
.agent-action-top { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 7px; }
.agent-action-top strong { font-size: 11px; }
.agent-action-top small { padding: 3px 6px; border-radius: 999px; color: var(--ink-faint); background: rgb(255 255 255 / 6%); font-size: 7px; text-transform: uppercase; }
.risk-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 8px currentColor; }
.risk-dot.risk-medium { background: var(--warning); }
.risk-dot.risk-high, .risk-dot.risk-critical { background: var(--danger); }
.agent-action-card p { margin: 0; color: var(--ink-soft); font-size: 10px; line-height: 1.45; }
.agent-action-card em { color: var(--ink-faint); font-size: 8px; font-style: normal; line-height: 1.4; }
.agent-action-card > div:last-child { display: flex; gap: 7px; }
.agent-action-card button { height: 34px; font-size: 9px; cursor: pointer; }
.agent-action-card button svg { width: 13px; }

.agent-history > button { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; width: 100%; padding: 15px 16px; border: 0; color: var(--ink); background: transparent; text-align: left; cursor: pointer; }
.agent-history > button > svg { width: 17px; color: var(--violet-soft); }
.agent-history > button > svg:last-child { color: var(--ink-faint); transition: transform 180ms ease; }
.agent-history > button.is-open > svg:last-child { transform: rotate(180deg); }
.agent-history > button span { display: grid; }
.agent-history > button strong { font-size: 11px; }
.agent-history > button small { margin-top: 2px; color: var(--ink-faint); font-size: 8px; }
.agent-history > div { display: grid; max-height: 340px; overflow-y: auto; padding: 0 10px 10px; border-top: 1px solid var(--line); }
.agent-history article { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 8px; padding: 10px 6px; border-bottom: 1px solid var(--line); }
.agent-history article:last-child { border-bottom: 0; }
.agent-history article > div { display: grid; min-width: 0; }
.agent-history article strong { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.agent-history article small { margin-top: 2px; color: var(--ink-faint); font-size: 8px; }
.agent-history article > button { display: grid; place-items: center; width: 29px; height: 29px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink-faint); background: rgb(255 255 255 / 4%); cursor: pointer; }
.agent-history article > button svg { width: 13px; }

.agent-document { padding: 14px; }
.agent-document > header { grid-template-columns: auto 1fr; }
.agent-document > div { display: grid; border-top: 1px solid var(--line); }
.agent-document article { display: grid; grid-template-columns: 37px minmax(0,1fr); align-items: center; gap: 8px; padding: 9px 2px; border-bottom: 1px solid var(--line); }
.agent-document article:last-child { border-bottom: 0; }
.agent-document article > span { display: grid; place-items: center; height: 24px; border-radius: 8px; color: var(--cyan); background: rgb(54 213 255 / 8%); font-size: 8px; font-weight: 780; }
.agent-document article > div { display: grid; min-width: 0; }
.agent-document article strong { font-size: 9px; }
.agent-document article small { overflow: hidden; margin-top: 2px; color: var(--ink-faint); font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.agent-document > p { margin: 8px 2px 2px; color: var(--ink-faint); font-size: 9px; }

.action-status { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-faint); }
.action-status.is-executed { background: var(--success); }
.action-status.is-rejected, .action-status.is-undone { background: var(--warning); }
.action-status.is-failed { background: var(--danger); }
.agent-loading { min-height: 440px; display: grid; place-items: center; align-content: center; gap: 12px; border-radius: 28px; color: var(--ink-faint); font-size: 12px; }
.agent-loading > svg { width: 27px; color: var(--violet-soft); }

/* Mobile agent */
.agent-mobile-shell {
  display: grid; grid-template-rows: auto 1fr auto;
  height: 100dvh; width: 100%; overflow: hidden;
}
.agent-mobile-header {
  display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 10px;
  padding: max(14px, env(safe-area-inset-top)) 14px 12px;
  border-bottom: 1px solid var(--line-strong);
  background: color-mix(in srgb, var(--surface-solid) 88%, transparent);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
}
.agent-mobile-header .agent-brand { display: flex; align-items: center; gap: 8px; }
.agent-mobile-header .agent-brand img { width: 28px; height: 28px; object-fit: contain; }
.agent-mobile-header .agent-brand strong { font-size: 13px; font-weight: 750; }
.agent-mode-selector {
  display: flex; align-items: center; gap: 3px;
  padding: 3px; border: 1px solid var(--line); border-radius: 12px;
  background: rgb(0 0 0 / 12%);
}
.agent-mode-selector button { min-height: 30px; padding: 0 9px; border: 0; border-radius: 9px; color: var(--ink-faint); background: transparent; font-size: 9px; font-weight: 700; cursor: pointer; transition: 160ms; }
.agent-mode-selector button.is-active { color: var(--ink); background: rgb(110 92 255 / 16%); }
.agent-mobile-messages { overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding: 16px 13px; }
.agent-mobile-messages .agent-message { max-width: 94%; }
.agent-mobile-messages .agent-message p { font-size: 14px; }
.agent-mobile-messages .agent-welcome { min-height: 350px; }
.agent-mobile-messages .agent-welcome > div { display: grid; width: 100%; }
.agent-mobile-messages .agent-welcome button { text-align: left; }

/* Responsive */
@media (max-width: 1100px) {
  .agent-workspace { grid-template-columns: minmax(0,1.5fr) minmax(260px,.65fr); }
  .agent-control { grid-template-columns: 1fr 1fr; }
  .agent-control > label { grid-column: 1 / -1; padding: 12px 0 0; border-left: 0; border-top: 1px solid var(--line); }
}

@media (max-width: 860px) {
  .agent-hero { grid-template-columns: auto 1fr; }
  .agent-hero-actions { grid-column: 1 / -1; max-width: none; justify-content: flex-start; }
  .agent-workspace { grid-template-columns: 1fr; min-height: 0; }
  .agent-conversation { min-height: 620px; }
  .agent-messages { max-height: 560px; }
  .agent-side { display: grid; grid-template-columns: 1fr 1fr; align-items: start; }
}

@media (max-width: 660px) {
  .agent-hero { grid-template-columns: 1fr; padding: 21px; border-radius: 25px; }
  .agent-orb { width: 64px; height: 64px; border-radius: 22px; }
  .agent-orb::before { width: 44px; height: 44px; }
  .agent-orb > span { width: 35px; height: 35px; }
  .agent-control { grid-template-columns: 1fr; }
  .agent-control > label { grid-column: auto; }
  .agent-workspace { gap: 12px; }
  .agent-conversation { min-height: 570px; border-radius: 24px; }
  .agent-messages { max-height: 510px; padding: 17px 13px; }
  .agent-message { max-width: 94%; }
  .agent-message p { font-size: 12px; }
  .agent-welcome { min-height: 350px; }
  .agent-welcome > div { display: grid; width: 100%; }
  .agent-welcome button { text-align: left; }
  .agent-composer { padding: 10px; }
  .agent-composer footer { line-height: 1.35; }
  .agent-side { display: flex; }
  .agent-actions { min-height: 250px; }
  .agent-provider { width: 100%; justify-content: center; }
}
