/* STAR Agent V1 — persistent assistant + full conversation workspace. */

:root {
  --star-agent-ink: #0e1914;
  --star-agent-dark: #102019;
  --star-agent-deep: #07130e;
  --star-agent-paper: #f6f8f3;
  --star-agent-white: #fff;
  --star-agent-lime: #d7fb82;
  --star-agent-mint: #dff8ec;
  --star-agent-aqua: #dff5f5;
  --star-agent-line: rgba(16, 32, 25, 0.12);
  --star-agent-muted: #68736c;
}

body[data-design-version="6.0"] .star-nav > .star-nav-agent {
  position: relative;
  padding-left: 28px;
  color: #fff;
  background: var(--star-agent-dark);
  box-shadow: 0 8px 20px rgba(16, 32, 25, 0.13);
}

body[data-design-version="6.0"] .star-nav > .star-nav-agent::before {
  content: "";
  position: absolute;
  left: 11px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--star-agent-lime);
  box-shadow: 0 0 0 4px rgba(215, 251, 130, 0.13);
  transform: translateY(-50%);
}

body[data-design-version="6.0"] .star-nav > .star-nav-agent:hover,
body[data-design-version="6.0"] .star-nav > .star-nav-agent[aria-current="page"] {
  color: #fff;
  background: #183126;
}

.star-agent-float {
  position: fixed;
  right: 22px;
  bottom: max(22px, env(safe-area-inset-bottom));
  z-index: 1200;
  display: grid;
  justify-items: end;
  gap: 12px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
}

body[data-page-family="agent-chat"] .star-agent-float { display: none; }

.star-agent-launcher {
  position: relative;
  display: grid;
  grid-template-columns: 42px auto;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 8px 16px 8px 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  color: #fff;
  background: rgba(10, 25, 18, 0.96);
  box-shadow: 0 22px 56px rgba(12, 29, 21, 0.25);
  cursor: pointer;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.star-agent-launcher__mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: var(--star-agent-dark);
  background: var(--star-agent-lime);
  font-size: 16px;
  font-weight: 900;
  letter-spacing: -0.06em;
}

.star-agent-launcher__copy {
  display: grid;
  gap: 2px;
  text-align: left;
}

.star-agent-launcher__copy strong {
  font-size: 12px;
  font-weight: 780;
}

.star-agent-launcher__copy small {
  color: rgba(255, 255, 255, 0.6);
  font-size: 9px;
  letter-spacing: 0.05em;
}

.star-agent-launcher__status {
  position: absolute;
  left: 42px;
  top: 7px;
  width: 8px;
  height: 8px;
  border: 2px solid #102019;
  border-radius: 50%;
  background: #7cf3b7;
}

.star-agent-panel {
  display: none;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(430px, calc(100vw - 28px));
  height: min(680px, calc(100dvh - 112px));
  overflow: hidden;
  border: 1px solid rgba(16, 32, 25, 0.14);
  border-radius: 28px;
  color: var(--star-agent-ink);
  background: rgba(248, 250, 246, 0.97);
  box-shadow: 0 32px 90px rgba(12, 29, 21, 0.24);
  backdrop-filter: blur(24px) saturate(1.15);
  -webkit-backdrop-filter: blur(24px) saturate(1.15);
}

.star-agent-float[data-open="true"] .star-agent-panel { display: grid; }
.star-agent-float[data-open="true"] .star-agent-launcher { display: none; }

.star-agent-panel__head,
.star-agent-workspace__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 17px 18px;
  color: #fff;
  background:
    radial-gradient(circle at 82% 0%, rgba(215, 251, 130, 0.17), transparent 9rem),
    var(--star-agent-dark);
}

.star-agent-panel__identity,
.star-agent-workspace__identity {
  display: grid;
  grid-template-columns: 34px auto;
  align-items: center;
  gap: 10px;
}

.star-agent-panel__identity > i,
.star-agent-workspace__identity > i {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  color: var(--star-agent-dark);
  background: var(--star-agent-lime);
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
}

.star-agent-panel__identity span,
.star-agent-workspace__identity span { display: grid; gap: 2px; }
.star-agent-panel__identity strong,
.star-agent-workspace__identity strong { font-size: 13px; }
.star-agent-panel__identity small,
.star-agent-workspace__identity small { color: rgba(255, 255, 255, 0.58); font-size: 9px; letter-spacing: 0.05em; }

.star-agent-panel__actions,
.star-agent-workspace__actions { display: flex; align-items: center; gap: 7px; }

.star-agent-history { position: relative; }
.star-agent-history > summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  color: #fff;
  background: rgba(255, 255, 255, 0.07);
  font-size: 9px;
  font-weight: 740;
  list-style: none;
  cursor: pointer;
}
.star-agent-history > summary::-webkit-details-marker { display: none; }
.star-agent-history > summary > i {
  display: grid;
  place-items: center;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  color: var(--star-agent-dark);
  background: var(--star-agent-lime);
  font-size: 8px;
  font-style: normal;
  font-weight: 900;
}
.star-agent-history[open] > summary { background: rgba(255, 255, 255, 0.14); }
.star-agent-history__popover {
  position: absolute;
  z-index: 20;
  top: calc(100% + 9px);
  right: 0;
  width: min(300px, calc(100vw - 34px));
  overflow: hidden;
  border: 1px solid rgba(16, 32, 25, 0.14);
  border-radius: 18px;
  color: var(--star-agent-ink);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 22px 60px rgba(10, 25, 18, 0.2);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.star-agent-history__popover > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 13px 10px;
  border-bottom: 1px solid var(--star-agent-line);
}
.star-agent-history__popover > header strong { font-size: 11px; }
.star-agent-history__popover > header small { color: var(--star-agent-muted); font-size: 9px; }
.star-agent-history__list { display: grid; gap: 5px; max-height: 330px; overflow-y: auto; padding: 7px; }
.star-agent-history__list > p { margin: 0; padding: 18px 10px; color: var(--star-agent-muted); font-size: 10px; text-align: center; }
.star-agent-panel__actions .star-agent-history__list button,
.star-agent-workspace__actions .star-agent-history__list button {
  display: grid;
  justify-items: start;
  gap: 3px;
  width: 100%;
  min-height: 0;
  padding: 10px 11px;
  border: 0;
  border-radius: 12px;
  color: var(--star-agent-ink);
  background: transparent;
  text-align: left;
}
.star-agent-history__list button:hover,
.star-agent-history__list button[aria-current="true"] { background: var(--star-agent-mint); }
.star-agent-history__list button strong { max-width: 100%; overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.star-agent-history__list button small { color: var(--star-agent-muted); font-size: 8px; }

.star-agent-panel__actions a,
.star-agent-panel__actions button,
.star-agent-workspace__actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  color: #fff;
  background: rgba(255, 255, 255, 0.07);
  font: inherit;
  font-size: 9px;
  font-weight: 740;
  text-decoration: none;
  cursor: pointer;
}

.star-agent-panel__actions button {
  width: 34px;
  padding: 0;
  font-size: 16px;
}

.star-agent-messages {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow-y: auto;
  padding: 18px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: rgba(16, 32, 25, 0.18) transparent;
}

.star-agent-message { display: grid; gap: 7px; max-width: 90%; }
.star-agent-message[data-role="user"] { align-self: end; }
.star-agent-message[data-role="assistant"] { align-self: start; }

.star-agent-message__bubble {
  padding: 13px 15px;
  border: 1px solid var(--star-agent-line);
  border-radius: 19px 19px 19px 6px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(16, 32, 25, 0.04);
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.star-agent-message[data-role="user"] .star-agent-message__bubble {
  border-color: var(--star-agent-dark);
  border-radius: 19px 19px 6px 19px;
  color: #fff;
  background: var(--star-agent-dark);
}

.star-agent-message__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.star-agent-message__meta span {
  padding: 5px 8px;
  border-radius: 999px;
  color: #35614f;
  background: var(--star-agent-mint);
  font-size: 8px;
  font-weight: 730;
  letter-spacing: 0.02em;
}

.star-agent-message[data-state="loading"] .star-agent-message__bubble {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 76px;
}

.star-agent-message[data-state="loading"] i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #74ae94;
  animation: star-agent-thinking 1.05s infinite ease-in-out;
}
.star-agent-message[data-state="loading"] i:nth-child(2) { animation-delay: 130ms; }
.star-agent-message[data-state="loading"] i:nth-child(3) { animation-delay: 260ms; }

@keyframes star-agent-thinking {
  0%, 70%, 100% { transform: translateY(0); opacity: 0.36; }
  35% { transform: translateY(-4px); opacity: 1; }
}

.star-agent-composer {
  display: grid;
  gap: 10px;
  padding: 13px;
  border-top: 1px solid var(--star-agent-line);
  background: rgba(255, 255, 255, 0.86);
}

.star-agent-context {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  color: #637169;
  font-size: 9px;
}
.star-agent-context::before { content: ""; flex: 0 0 auto; width: 7px; height: 7px; border-radius: 50%; background: #68d6a0; }
.star-agent-context span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.star-agent-human {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid rgba(16, 32, 25, 0.11);
  border-radius: 15px;
  background: linear-gradient(110deg, rgba(223, 248, 236, 0.88), rgba(255, 255, 255, 0.94));
}

.star-agent-human__identity {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.star-agent-human__identity > i {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 10px;
  color: #fff;
  background: var(--star-agent-dark);
  font-size: 9px;
  font-style: normal;
  font-weight: 900;
}

.star-agent-human__identity > span { display: grid; gap: 1px; min-width: 0; }
.star-agent-human__identity strong { color: var(--star-agent-ink); font-size: 10px; }
.star-agent-human__identity small { color: var(--star-agent-muted); font-size: 8px; white-space: nowrap; }
.star-agent-human nav { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
.star-agent-human a {
  display: inline-flex;
  align-items: center;
  min-height: 27px;
  padding: 5px 8px;
  border: 1px solid rgba(16, 32, 25, 0.12);
  border-radius: 999px;
  color: #294638;
  background: rgba(255, 255, 255, 0.9);
  font-size: 8px;
  font-weight: 760;
  text-decoration: none;
}

.star-agent-human a:last-child { color: #fff; border-color: var(--star-agent-dark); background: var(--star-agent-dark); }
.star-agent-human a:hover { border-color: rgba(16, 32, 25, 0.32); }
.star-agent-human a:focus-visible { outline: 3px solid rgba(104, 214, 160, 0.36); outline-offset: 2px; }

.star-agent-suggestions {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.star-agent-suggestions::-webkit-scrollbar { display: none; }
.star-agent-suggestions button {
  flex: 0 0 auto;
  min-height: 30px;
  padding: 6px 10px;
  border: 1px solid var(--star-agent-line);
  border-radius: 999px;
  color: #32493e;
  background: #fff;
  font: inherit;
  font-size: 9px;
  cursor: pointer;
}

.star-agent-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 8px;
  padding: 6px;
  border: 1px solid rgba(16, 32, 25, 0.16);
  border-radius: 19px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(16, 32, 25, 0.05);
}

.star-agent-form textarea {
  min-height: 42px;
  max-height: 130px;
  resize: none;
  padding: 10px;
  border: 0;
  outline: 0;
  color: var(--star-agent-ink);
  background: transparent;
  font: inherit;
  font-size: 13px;
  line-height: 1.45;
}

.star-agent-form button {
  align-self: end;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 14px;
  color: var(--star-agent-dark);
  background: var(--star-agent-lime);
  font-size: 18px;
  font-weight: 900;
  cursor: pointer;
}
.star-agent-form button:disabled { opacity: 0.45; cursor: wait; }

/* Full-page agent workspace */

body[data-page-family="agent-chat"] .star-task-route,
body[data-page-family="agent-chat"] .star-system-presence { display: none; }

.star-agent-page { min-height: calc(100dvh - 74px); padding: 10px 0 24px; }

.star-agent-stage {
  display: grid;
  grid-template-columns: minmax(420px, 0.92fr) minmax(0, 1.38fr);
  width: 100%;
  min-height: calc(100dvh - 74px);
  margin: 0 auto;
  overflow: hidden;
  border-block: 1px solid var(--star-agent-line);
  border-inline: 0;
  border-radius: 0;
  background: #fff;
  box-shadow: 0 28px 86px rgba(16, 32, 25, 0.12);
}

.star-agent-stage__map {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
  padding: clamp(28px, 3.2vw, 50px);
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(circle at 20% 0%, rgba(116, 214, 160, 0.18), transparent 18rem),
    radial-gradient(circle at 100% 88%, rgba(215, 251, 130, 0.12), transparent 22rem),
    var(--star-agent-deep);
}

.star-agent-stage__map::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.22;
  background-image:
    linear-gradient(rgba(255,255,255,.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.08) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, #000, transparent 80%);
}

.star-agent-stage__copy,
.star-agent-runtime,
.star-agent-boundary { position: relative; z-index: 1; }
.star-agent-stage__copy { display: grid; gap: 16px; }
.star-agent-stage__copy > span { color: var(--star-agent-lime); font-size: 10px; font-weight: 760; letter-spacing: 0.14em; }
.star-agent-stage__copy h1 { max-width: 520px; margin: 0; font-size: clamp(42px, 4vw, 62px); line-height: 0.97; letter-spacing: -0.065em; }
.star-agent-stage__copy p { max-width: 560px; margin: 0; color: rgba(255,255,255,.63); font-size: 14px; line-height: 1.7; }

.star-agent-runtime { display: grid; gap: 9px; margin-top: auto; }
.star-agent-runtime article {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  min-height: 62px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.05);
}
.star-agent-runtime article > i { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; color: var(--star-agent-dark); background: var(--star-agent-lime); font-size: 9px; font-style: normal; font-weight: 900; }
.star-agent-runtime article > span { display: grid; gap: 2px; }
.star-agent-runtime article strong { font-size: 11px; }
.star-agent-runtime article small { color: rgba(255,255,255,.5); font-size: 9px; }
.star-agent-runtime article > em { color: #80e9b1; font-size: 8px; font-style: normal; font-weight: 800; }

.star-agent-boundary { display: flex; align-items: center; gap: 9px; padding-top: 18px; border-top: 1px solid rgba(255,255,255,.1); color: rgba(255,255,255,.52); font-size: 9px; line-height: 1.5; }
.star-agent-boundary i { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: #80e9b1; box-shadow: 0 0 0 5px rgba(128,233,177,.1); }

.star-agent-workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  background:
    radial-gradient(circle at 100% 0%, rgba(223, 248, 236, 0.78), transparent 25rem),
    #f8faf6;
}

.star-agent-workspace__head { color: var(--star-agent-ink); background: rgba(255,255,255,.72); border-bottom: 1px solid var(--star-agent-line); backdrop-filter: blur(14px); }
.star-agent-workspace__identity > i { color: #fff; background: var(--star-agent-dark); }
.star-agent-workspace__identity small { color: #718078; }
.star-agent-workspace__actions button { color: var(--star-agent-ink); border-color: var(--star-agent-line); background: #fff; }
.star-agent-workspace__actions .star-agent-history > summary { color: var(--star-agent-ink); border-color: var(--star-agent-line); background: #fff; }
.star-agent-workspace__actions .star-agent-history[open] > summary { background: var(--star-agent-mint); }
.star-agent-workspace .star-agent-messages { padding: clamp(20px, 3vw, 42px); }
.star-agent-workspace .star-agent-message { max-width: min(82%, 760px); }
.star-agent-workspace .star-agent-message__bubble { padding: 16px 18px; font-size: 14px; }
.star-agent-workspace .star-agent-composer { padding: 16px clamp(20px, 3vw, 42px) 22px; background: rgba(248,250,246,.88); }

@media (max-width: 1180px) {
  body[data-design-version="6.0"] .star-nav > .star-nav-agent { padding-left: 24px; }
  body[data-design-version="6.0"] .star-nav > .star-nav-agent::before { left: 9px; }
  .star-agent-stage { grid-template-columns: minmax(370px, .88fr) minmax(0, 1.35fr); }
}

@media (max-width: 1120px) {
  .star-agent-stage { grid-template-columns: 1fr; min-height: 0; }
  .star-agent-stage__map { display: none; }
  .star-agent-workspace { min-height: calc(100dvh - 74px); }
}

@media (max-width: 680px) {
  .star-agent-float { right: 10px; bottom: max(10px, env(safe-area-inset-bottom)); }
  .star-agent-launcher { min-height: 54px; }
  .star-agent-panel {
    width: calc(100vw - 20px);
    height: min(84dvh, 720px);
    border-radius: 24px;
  }
  .star-agent-panel__head { padding: 13px; }
  .star-agent-panel__actions a { font-size: 0; width: 34px; padding: 0; }
  .star-agent-panel__actions a::before { content: "↗"; font-size: 14px; }
  .star-agent-page { padding: 10px 0; }
  .star-agent-stage { width: 100%; border-radius: 0; }
  .star-agent-stage__map { display: none; }
  .star-agent-stage__copy h1 { font-size: clamp(38px, 13vw, 58px); }
  .star-agent-workspace { min-height: calc(100dvh - 67px); }
  .star-agent-workspace__head { gap: 8px; padding: 12px 14px; }
  .star-agent-workspace__identity { min-width: 0; }
  .star-agent-workspace__identity > span { min-width: 0; }
  .star-agent-workspace__identity strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
  .star-agent-workspace__identity small { font-size: 8px; line-height: 1.35; }
  .star-agent-workspace__actions button { flex: 0 0 auto; max-width: none; font-size: 8px; }
  .star-agent-workspace__actions { gap: 5px; }
  .star-agent-workspace__actions > [data-star-agent-reset],
  .star-agent-workspace__actions > [data-star-agent-return] { width: 36px; min-width: 36px; padding: 0; font-size: 0; }
  .star-agent-workspace__actions > [data-star-agent-reset]::before { content: "+"; font-size: 15px; }
  .star-agent-workspace__actions > [data-star-agent-return]::before { content: "↗"; font-size: 13px; }
  .star-agent-history__label { font-size: 0; }
  .star-agent-history__label::before { content: "◷"; font-size: 14px; }
  .star-agent-history > summary { min-width: 50px; padding: 0 6px; }
  .star-agent-workspace .star-agent-message { max-width: 94%; }
  .star-agent-workspace .star-agent-messages { padding: 18px 13px; }
  .star-agent-workspace .star-agent-composer { padding: 12px; }
  .star-agent-human { align-items: flex-start; }
  .star-agent-human nav { max-width: 160px; }
}

@media (prefers-reduced-motion: reduce) {
  .star-agent-message[data-state="loading"] i { animation: none; }
}
