:root {
  --bg: #f6f6fc;
  --bg-soft: #eeeef8;
  --card: #ffffff;
  --ink: #1e1b2e;
  --muted: #6b7280;
  --line: #dedff0;
  --brand: #6d5ce7;
  --brand-ink: #5142c7;
  --brand-soft: #e9e7ff;
  --sky: #38a5e0;
  --green: #34b36b;
  --rose: #ec4a8b;
  --gold: #e8912a;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(30, 27, 46, 0.05), 0 18px 45px rgba(30, 27, 46, 0.09);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Plus Jakarta Sans", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 55% 22%, #ffffff 0%, #f7f7fd 42%, var(--bg-soft) 100%);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
body.agent-open { overflow: hidden; }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 224px;
  background: rgba(255, 255, 255, 0.62);
  backdrop-filter: blur(18px);
  border-right: 1px solid var(--line);
  padding: 1.2rem 0.75rem 0.9rem;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.sidebar-brand-row { display: flex; align-items: center; justify-content: space-between; gap: 0.65rem; }
.brand { display: flex; align-items: center; gap: 0.55rem; text-decoration: none; min-width: 0; }
.brand > div { min-width: 0; }
.brand h1 { margin: 0; font-size: 1.02rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1; }
.brand span {
  font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.16em;
  color: var(--muted); font-weight: 700;
}
.brand-logo {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid rgba(30, 27, 46, 0.1); background: #fff; padding: 2px;
  box-shadow: 0 10px 24px rgba(30, 27, 46, 0.08);
  object-fit: contain;
}
.sidebar-toggle-btn,
.sidebar-reopen {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(30, 27, 46, 0.09);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--brand-ink);
  cursor: pointer;
  font: inherit;
  font-size: 1.35rem;
  line-height: 1;
  box-shadow: 0 8px 20px rgba(30, 27, 46, 0.07);
}
.sidebar-toggle-btn:hover,
.sidebar-reopen:hover { border-color: rgba(109, 92, 231, 0.34); color: var(--brand); }
.sidebar-reopen {
  position: fixed;
  left: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 55;
  border-radius: 999px;
}
.sidebar-reopen[hidden] { display: none; }
body.sidebar-collapsed .sidebar {
  display: none;
}
body.sidebar-collapsed .content-shell { width: 100%; }
body.sidebar-collapsed.dashboard-route .container { padding-left: 1.3rem; }

.side-nav {
  margin-top: 0.85rem; display: flex; flex-direction: column; flex: 1; min-height: 0;
}
.side-nav-main {
  display: grid; gap: 0.08rem; flex: 1; min-height: 0;
  align-content: start; grid-auto-rows: max-content;
  overflow-y: auto; overflow-x: hidden; padding-right: 0.25rem;
}
.side-nav-main::-webkit-scrollbar { width: 6px; }
.side-nav-main::-webkit-scrollbar-thumb { background: #cfd8e6; border-radius: 3px; }
.side-nav-bottom {
  flex: none; display: grid; gap: 0.14rem; border-top: 1px solid var(--line);
  padding-top: 0.55rem; margin-top: 0.55rem;
}
.side-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  min-height: 28px;
  line-height: 1.15;
  text-decoration: none; color: var(--muted); font-size: 0.76rem; font-weight: 650;
  padding: 0.26rem 0.42rem; border-radius: 8px; transition: all 0.15s ease;
}
.side-link:hover { color: var(--ink); background: #fff; }
.side-link.active { color: var(--brand-ink); background: #fff; box-shadow: 0 9px 22px rgba(30, 27, 46, 0.07); }
.side-apps { display: grid; gap: 0.1rem; }
.side-apps-summary {
  list-style: none;
  cursor: pointer;
}
.side-apps-summary::-webkit-details-marker { display: none; }
.side-caret {
  flex: none;
  font-size: 0.9rem;
  line-height: 1;
  color: #9aa1ac;
  transition: transform 0.15s ease, color 0.15s ease;
}
.side-apps[open] .side-caret {
  transform: rotate(90deg);
  color: var(--brand);
}
.side-apps-panel {
  display: grid;
  gap: 0.04rem;
  align-content: start;
  grid-auto-rows: max-content;
  margin: 0.12rem 0 0.08rem;
  padding: 0.08rem 0 0.16rem 0.32rem;
  border-left: 1px solid rgba(30, 27, 46, 0.08);
}
.side-user {
  font-size: 0.75rem; color: var(--muted); padding: 0.25rem 0.65rem;
  text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700;
}

/* ---------- Content ---------- */
.content-shell { flex: 1; min-width: 0; }
.page-head {
  padding: 1.6rem 2rem 0.4rem;
  border-bottom: 1px solid transparent;
}
.page-head h2 { margin: 0; font-size: 1.4rem; font-weight: 800; letter-spacing: -0.02em; }
.container { padding: 1rem 2rem 3rem; max-width: 1120px; }
.dashboard-route .page-head { display: none; }
.dashboard-route .container { max-width: none; padding: 1.1rem 1.3rem 2rem; }

.lede { color: var(--muted); font-size: 1rem; margin: 0.2rem 0 1.8rem; }

/* ---------- Tool groups ---------- */
.tool-group { margin-bottom: 2.4rem; }
.group-head { margin-bottom: 0.9rem; }
.group-head h3 { margin: 0; font-size: 1.05rem; font-weight: 700; }
.group-head p { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.88rem; }

.tile-grid {
  display: grid; gap: 0.85rem;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.tile {
  display: flex; align-items: center; gap: 0.9rem;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.05rem; text-decoration: none; color: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.tile:hover {
  transform: translateY(-2px); box-shadow: var(--shadow);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}
.tile-icon {
  flex: none; width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 12%, #fff);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line));
}
.tile-icon-svg { width: 22px; height: 22px; }
.tile-body { display: grid; gap: 0.1rem; flex: 1; min-width: 0; }
.tile-name { font-weight: 700; font-size: 0.98rem; }
.tile-tagline { color: var(--muted); font-size: 0.83rem; }
.tile-meta { display: flex; align-items: center; gap: 0.5rem; flex: none; }
.tile-arrow { color: var(--muted); font-size: 1.1rem; }
.tile:hover .tile-arrow { color: var(--accent); }
.tile-local { border-style: dashed; }

.badge {
  font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  padding: 0.2rem 0.5rem; border-radius: 999px;
  background: var(--bg-soft); color: var(--muted); border: 1px solid var(--line);
  white-space: nowrap;
}

/* ---------- Cards / detail ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.5rem 1.6rem; box-shadow: var(--shadow); max-width: 820px;
}
.card.empty { color: var(--muted); }
.back-link { text-decoration: none; color: var(--muted); font-weight: 600; font-size: 0.9rem; }
.back-link:hover { color: var(--brand-ink); }

.tool-detail-head { display: flex; gap: 1rem; align-items: flex-start; margin-bottom: 1.2rem; }
.tool-detail-head h3 { margin: 0 0 0.15rem; font-size: 1.2rem; }
.run-summary { color: var(--muted); }
.run-steps {
  background: #0f172a; color: #e2e8f0; border-radius: 12px; padding: 1rem 1.1rem;
  overflow-x: auto; font-size: 0.85rem; line-height: 1.7;
}
.run-steps code { font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.muted { color: var(--muted); font-size: 0.85rem; }

/* ---------- Prose (rendered skill markdown) ---------- */
.prose { line-height: 1.7; }
.prose h1 { font-size: 1.5rem; margin-top: 0; letter-spacing: -0.02em; }
.prose h2 { font-size: 1.2rem; margin-top: 1.8rem; }
.prose h3 { font-size: 1.02rem; margin-top: 1.4rem; }
.prose p, .prose li { color: #1e293b; }
.prose code {
  background: var(--bg-soft); padding: 0.12rem 0.36rem; border-radius: 6px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.86em;
}
.prose pre {
  background: #0f172a; color: #e2e8f0; padding: 1rem 1.1rem; border-radius: 12px;
  overflow-x: auto;
}
.prose pre code { background: none; padding: 0; color: inherit; }
.prose a { color: var(--brand-ink); text-decoration: underline; }
.prose blockquote {
  border-left: 3px solid var(--brand); margin: 1rem 0; padding: 0.3rem 1rem;
  color: var(--muted); background: var(--brand-soft); border-radius: 0 8px 8px 0;
}
.prose table { border-collapse: collapse; width: 100%; }
.prose th, .prose td { border: 1px solid var(--line); padding: 0.5rem 0.7rem; text-align: left; }

/* ---------- Auth ---------- */
.app-auth {
  background:
    radial-gradient(circle at 50% 25%, #ffffff 0%, #f7f7fd 44%, #eeeef8 100%);
}
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 2rem; }
.auth-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 20px;
  padding: 2.2rem 2.2rem 2rem; width: 100%; max-width: 400px; box-shadow: var(--shadow);
}
.auth-brand { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 1.6rem; }
.auth-brand h1 { margin: 0; font-size: 1.15rem; font-weight: 800; }
.auth-brand span {
  font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.16em;
  color: var(--muted); font-weight: 700;
}
.auth-title { margin: 0; font-size: 1.4rem; font-weight: 800; letter-spacing: -0.02em; }
.auth-subtitle { color: var(--muted); margin: 0.25rem 0 1.4rem; font-size: 0.92rem; }
.auth-form { display: grid; gap: 0.9rem; }
.auth-form label { display: grid; gap: 0.35rem; font-size: 0.82rem; font-weight: 700; color: var(--muted); }
.auth-form input {
  padding: 0.65rem 0.8rem; border: 1px solid var(--line); border-radius: 10px;
  font-size: 0.95rem; font-family: inherit; background: #fff; color: var(--ink);
}
.auth-form input:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
button[type="submit"] {
  margin-top: 0.3rem; padding: 0.7rem 1rem; border: none; border-radius: 10px;
  background: var(--brand); color: #fff; font-weight: 700; font-size: 0.95rem;
  cursor: pointer; font-family: inherit; transition: background 0.15s ease;
}
button[type="submit"]:hover { background: var(--brand-ink); }
.error {
  background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca;
  padding: 0.6rem 0.8rem; border-radius: 10px; font-size: 0.88rem; margin: 0 0 1rem;
}

/* ---------- Sidebar groups ---------- */
.side-group-label {
  font-size: 0.52rem; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--muted); font-weight: 800; margin: 0.46rem 0 0.08rem 0.4rem; opacity: 0.75;
}
.side-sublink {
  display: flex; align-items: center; gap: 0.42rem; text-decoration: none;
  color: var(--muted); font-size: 0.7rem; font-weight: 600;
  min-height: 25px;
  line-height: 1.15;
  padding: 0.22rem 0.38rem; border-radius: 7px; transition: all 0.15s ease;
}
.side-sublink:hover { color: var(--ink); background: #fff; }
.side-sublink.active { color: var(--brand-ink); background: var(--brand-soft); }
.side-dot { width: 7px; height: 7px; border-radius: 3px; flex: none; }
.side-sublink span:nth-child(2) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-ext { font-size: 0.75rem; opacity: 0.55; }

/* ---------- Hero + chat ---------- */
.hero {
  background: linear-gradient(150deg, var(--brand-soft) 0%, #fff 60%);
  border: 1px solid var(--line); border-radius: 20px;
  padding: 1.4rem 1.6rem; margin-bottom: 1.8rem; box-shadow: var(--shadow);
}
.hero-head h1 { margin: 0; font-size: 1.4rem; font-weight: 800; letter-spacing: -0.02em; }
.hero-head p { margin: 0.15rem 0 1rem; color: var(--muted); }
.chat { display: flex; flex-direction: column; gap: 0.6rem; }
.chat-log {
  display: flex; flex-direction: column; gap: 0.5rem; max-height: 210px;
  overflow-y: auto; padding-right: 0.2rem;
}
.chat-msg { display: flex; }
.chat-msg.user { justify-content: flex-end; }
.chat-bubble {
  max-width: 80%; padding: 0.6rem 0.85rem; border-radius: 14px; font-size: 0.9rem; line-height: 1.5;
  white-space: pre-wrap;
}
.chat-msg.assistant .chat-bubble { background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.chat-msg.user .chat-bubble { background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.chat-input { display: flex; gap: 0.5rem; }
.chat-input input {
  flex: 1; padding: 0.7rem 0.9rem; border: 1px solid var(--line); border-radius: 12px;
  font-size: 0.95rem; font-family: inherit; background: #fff;
}
.chat-input input:focus { outline: 2px solid var(--brand); border-color: var(--brand); }
.chat-input button {
  padding: 0.7rem 1.2rem; border: none; border-radius: 12px; background: var(--brand);
  color: #fff; font-weight: 700; cursor: pointer; font-family: inherit;
}
.chat-input button:hover { background: var(--brand-ink); }
.chat-input button:disabled, .chat-input input:disabled { opacity: 0.55; cursor: not-allowed; }
.chat-disabled { opacity: 0.85; }

/* ---------- HabitOS home ---------- */
.nexus-home {
  min-height: calc(100vh - 2.2rem);
  border: 0;
  border-radius: 0;
  padding: 0.75rem 0 1.2rem;
  background:
    radial-gradient(circle at 50% 30%, rgba(255, 255, 255, 0.98) 0%, rgba(246, 246, 252, 0.94) 46%, rgba(238, 238, 248, 0.92) 100%);
  box-shadow: none;
  overflow: visible;
}

.nexus-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.75rem;
}
.eyebrow {
  display: block;
  margin: 0 0 0.25rem;
  font-size: 0.68rem;
  line-height: 1.2;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brand);
  font-weight: 800;
}
.nexus-topbar h1 {
  margin: 0;
  font-size: 2.35rem;
  line-height: 0.98;
  letter-spacing: -0.03em;
}
.nexus-status { display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; justify-content: flex-end; }
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid rgba(30, 27, 46, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  padding: 0.42rem 0.65rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.status-pill:where(button) { cursor: default; font-family: inherit; }
.status-pill::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(52, 179, 107, 0.14);
}
.status-pill.off::before { background: var(--gold); box-shadow: 0 0 0 3px rgba(232, 145, 42, 0.16); }
.stack-status {
  position: relative;
}
.stack-hover {
  position: absolute;
  right: 0;
  top: calc(100% + 0.55rem);
  width: min(360px, calc(100vw - 2rem));
  display: grid;
  gap: 0.55rem;
  padding: 0.75rem;
  border: 1px solid rgba(30, 27, 46, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 22px 52px rgba(30, 27, 46, 0.16);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 0.14s ease, transform 0.14s ease;
  z-index: 30;
}
.stack-status:hover .stack-hover,
.stack-status:focus-within .stack-hover {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.nexus-ticker {
  position: sticky;
  top: 0;
  z-index: 65;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin: -1.1rem -1.3rem 0.75rem;
  padding: 0.75rem 1.3rem;
  background: rgba(246, 246, 252, 0.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(30, 27, 46, 0.07);
  box-shadow: 0 10px 30px rgba(30, 27, 46, 0.06);
}
.ticker-item {
  position: relative;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  border: 1px solid rgba(30, 27, 46, 0.08);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 28px rgba(30, 27, 46, 0.07);
  padding: 0.65rem 0.8rem;
}
.context-kicker {
  flex: none;
  color: var(--brand);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.ticker-item > strong {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem;
  line-height: 1.2;
}
.ticker-panel {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 0.5rem);
  max-height: min(480px, calc(100vh - 170px));
  overflow: auto;
  border: 1px solid rgba(30, 27, 46, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 22px 52px rgba(30, 27, 46, 0.16);
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 0.14s ease, transform 0.14s ease;
}
.ticker-item:hover .ticker-panel,
.ticker-item:focus-within .ticker-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.context-panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.55rem;
}
.context-panel-head h3 { margin: 0; font-size: 1rem; }

.nexus-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  align-items: stretch;
}
.orbit-stage {
  position: relative;
  --orbit-radius: min(33vw, 335px);
  --node-size: clamp(116px, 9vw, 144px);
  width: min(100%, 1120px);
  height: clamp(660px, 64vw, 780px);
  margin: 0 auto;
  border-radius: 22px;
  background:
    radial-gradient(circle at 50% 50%, #ffffff 0%, rgba(255, 255, 255, 0.88) 23%, rgba(245, 245, 252, 0.42) 58%, transparent 75%);
  overflow: visible;
}
.orbit-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.orbit-spoke {
  stroke: #bdb8ea;
  stroke-width: 2;
  stroke-dasharray: 3 13;
}
.orbit-end-dot {
  fill: var(--brand);
  filter: drop-shadow(0 3px 7px rgba(109, 92, 231, 0.34));
}
.orbit-runner {
  fill: var(--brand);
  filter: drop-shadow(0 0 10px rgba(109, 92, 231, 0.58));
}
.agent-launcher {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: clamp(260px, 26vw, 310px);
  min-height: 260px;
  border-radius: 26px;
  padding: 1.2rem;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(109, 92, 231, 0.22);
  box-shadow: 0 24px 70px rgba(30, 27, 46, 0.18);
  z-index: 4;
  cursor: pointer;
  color: inherit;
  font: inherit;
  display: grid;
  justify-items: start;
  align-content: center;
  text-align: left;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}
.agent-launcher:hover {
  transform: translate(-50%, -50%) translateY(-4px);
  box-shadow: 0 30px 80px rgba(30, 27, 46, 0.22);
}
.agent-launcher:focus-visible { outline: 3px solid rgba(109, 92, 231, 0.35); outline-offset: 3px; }
.core-mark {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  padding: 2px;
  background: #fff;
  border: 1px solid rgba(30, 27, 46, 0.08);
  box-shadow: 0 14px 30px rgba(30, 27, 46, 0.16);
  overflow: hidden;
}
.core-mark img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: contain;
}
.core-copy { display: block; margin: 0.85rem 0 0; }
.core-title,
.core-copy h2 { display: block; margin: 0; font-size: 1.35rem; font-weight: 800; line-height: 1.12; letter-spacing: -0.03em; }
.core-copy small { display: block; margin-top: 0.8rem; color: var(--brand-ink); font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; }
.agent-quick-form {
  display: flex;
  gap: 0.4rem;
  width: 100%;
  margin-top: 1rem;
  padding: 0.35rem;
  border: 1px solid rgba(30, 27, 46, 0.08);
  border-radius: 15px;
  background: #f7f7fb;
}
.agent-quick-form input {
  min-width: 0;
  flex: 1;
  border: 0;
  background: transparent;
  padding: 0.58rem 0.55rem;
  color: var(--ink);
  font: inherit;
  font-size: 0.86rem;
}
.agent-quick-form input:focus { outline: none; }
.agent-quick-form button {
  margin: 0;
  border: 0;
  border-radius: 11px;
  background: var(--brand);
  color: #fff;
  padding: 0.58rem 0.7rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
}
.agent-popout {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 1.2rem;
}
.agent-popout[hidden] { display: none; }
.agent-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(30, 27, 46, 0.28);
  backdrop-filter: blur(7px);
  cursor: pointer;
}
.agent-panel {
  position: relative;
  z-index: 1;
  width: min(720px, 100%);
  max-height: min(760px, calc(100vh - 2.4rem));
  display: flex;
  flex-direction: column;
  gap: 1rem;
  border: 1px solid rgba(109, 92, 231, 0.2);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 36px 90px rgba(30, 27, 46, 0.28);
  padding: 1.25rem;
}
.agent-panel-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.85rem;
  align-items: center;
}
.agent-panel-head h2 { margin: 0; font-size: 1.35rem; line-height: 1.12; letter-spacing: -0.03em; }
.agent-close {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(30, 27, 46, 0.09);
  border-radius: 12px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 1.4rem;
  line-height: 1;
}
.agent-panel .chat { min-height: 0; }
.agent-panel .chat-log {
  max-height: min(430px, calc(100vh - 300px));
  min-height: 220px;
}
.agent-panel .chat-bubble { max-width: 92%; }
.agent-panel .chat-input {
  background: #f7f7fb;
  border: 1px solid rgba(30, 27, 46, 0.08);
  border-radius: 16px;
  padding: 0.35rem;
}
.agent-panel .chat-input input { border: 0; background: transparent; padding: 0.75rem 0.8rem; min-width: 0; }
.agent-panel .chat-input button { margin: 0; border-radius: 12px; padding: 0.72rem 1rem; }

.orbit-node {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--node-size);
  transform: translate(-50%, -50%) rotate(var(--angle)) translateX(var(--orbit-radius)) rotate(var(--counter-angle));
  z-index: 3;
}
.node-card {
  display: flex;
  min-height: clamp(108px, 8.8vw, 131px);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  text-align: center;
  text-decoration: none;
  color: inherit;
  border-radius: 17px;
  padding: 0.76rem 0.66rem;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(30, 27, 46, 0.07);
  box-shadow: 0 14px 34px rgba(30, 27, 46, 0.1);
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}
.node-card:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
  box-shadow: 0 20px 46px rgba(30, 27, 46, 0.15);
}
.node-icon {
  width: 40px;
  height: 40px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 13%, #fff);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line));
}
.node-icon .tile-icon-svg { width: 22px; height: 22px; }
.node-group {
  color: var(--muted);
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.node-name {
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1.18;
  overflow-wrap: anywhere;
}
.node-action {
  color: var(--accent);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.orbit-node .cred-mini { top: -0.25rem; right: -0.25rem; }

.integration-pill {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(30, 27, 46, 0.08);
  border-radius: 17px;
  padding: 0.72rem;
  box-shadow: 0 12px 28px rgba(30, 27, 46, 0.08);
}
.integration-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  flex: none;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: var(--brand);
  background: var(--brand-soft);
}
.integration-pill.google .integration-icon { color: #4285f4; background: #eef5ff; }
.integration-pill.notion .integration-icon { color: #111; background: #f4f4f2; }
.integration-pill.data .integration-icon { color: var(--green); background: #ddf3e4; }
.integration-pill.hubspot .integration-icon { color: #ff7a59; background: #ffede6; }
.integration-pill span:last-child { display: grid; min-width: 0; }
.integration-state {
  font-size: 0.55rem;
  line-height: 1.1;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 800;
  color: #9aa1ac;
}
.integration-pill strong { font-size: 0.84rem; line-height: 1.15; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.integration-pill small { color: var(--muted); font-size: 0.7rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 1180px) {
  .nexus-layout { grid-template-columns: minmax(0, 1fr); }
  .orbit-stage {
    --orbit-radius: min(34vw, 300px);
    --node-size: clamp(112px, 12vw, 136px);
    width: min(100%, 860px);
    height: clamp(620px, 78vw, 720px);
  }
  .agent-launcher { width: clamp(250px, 34vw, 290px); }
}

@media (max-width: 820px) {
  .dashboard-route .container { padding: 0.8rem; }
  .nexus-home { padding: 0.75rem 0 1rem; border-radius: 0; }
  .nexus-topbar { display: grid; }
  .nexus-topbar h1 { font-size: 1.45rem; }
  .nexus-ticker { margin: -0.8rem -0.8rem 0.75rem; padding: 0.65rem 0.8rem; }
  .nexus-ticker,
  .stack-hover { grid-template-columns: 1fr; }
  .ticker-panel,
  .stack-hover { position: static; margin-top: 0.5rem; max-height: none; opacity: 1; pointer-events: auto; transform: none; }
  .orbit-stage {
    display: grid;
    gap: 0.8rem;
    min-height: 0;
    overflow: visible;
  }
  .orbit-lines { display: none; }
  .agent-launcher,
  .orbit-node {
    position: static;
    transform: none;
    width: 100%;
    min-width: 0;
  }
  .agent-launcher { min-height: 0; }
  .agent-launcher:hover { transform: none; }
  .orbit-node { display: block; }
  .node-card {
    min-height: 0;
    flex-direction: row;
    justify-content: flex-start;
    text-align: left;
  }
  .node-group { display: none; }
  .node-action { margin-left: auto; white-space: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
  .orbit-runner { display: none; }
}

/* ---------- Dashboard row: Schedule + Apps side by side ---------- */
.dash-row {
  display: grid;
  grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
  gap: 1.1rem;
  align-items: start;
  margin-bottom: 1.8rem;
  min-width: 0;
}
.dash-row .sched-card { margin-bottom: 0; min-width: 0; }
.dash-col { display: grid; gap: 1.1rem; align-content: start; min-width: 0; max-width: 100%; }
@media (max-width: 760px) {
  .dash-row { grid-template-columns: 1fr; }
}

/* ---------- Unread mail card ---------- */
.mail-item {
  display: block; padding: 0.5rem 0; border-top: 1px solid var(--bg-soft);
  text-decoration: none; color: inherit; min-width: 0; max-width: 100%;
}
.mail-item:first-child { border-top: none; }
.mail-item:hover .mail-subject { color: var(--brand-ink); }
.mail-body { display: flex; flex-direction: column; min-width: 0; max-width: 100%; gap: 0.1rem; }
.mail-top { display: flex; align-items: baseline; justify-content: space-between; gap: 0.6rem; min-width: 0; }
.mail-from { font-size: 0.82rem; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-time { font-size: 0.72rem; color: var(--muted); white-space: nowrap; flex: none; }
.mail-subject {
  font-size: 0.88rem; font-weight: 600; line-height: 1.35;
  overflow-wrap: anywhere; word-break: break-word;
}
.mail-snippet {
  font-size: 0.78rem; color: var(--muted); line-height: 1.35;
  display: -webkit-box; overflow: hidden; overflow-wrap: anywhere; word-break: break-word;
  -webkit-box-orient: vertical; -webkit-line-clamp: 2;
}

/* ---------- Schedule ---------- */
.sched-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  padding: 1.1rem 1.3rem 1.2rem; margin-bottom: 1.8rem; box-shadow: var(--shadow);
  min-width: 0; max-width: 100%; overflow: hidden;
}
.sched-card > div[id$="Mount"] { min-width: 0; max-width: 100%; }
.sched-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.6rem; min-width: 0; }
.sched-head h3 { margin: 0; font-size: 1.05rem; font-weight: 800; letter-spacing: -0.01em; }
.sched-more { font-size: 0.82rem; font-weight: 700; color: var(--brand-ink); text-decoration: none; white-space: nowrap; }
.sched-more:hover { text-decoration: underline; }
.sched-page { max-width: 760px; }

.sched-day {
  font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); margin: 0.9rem 0 0.4rem;
}
.sched-day:first-child { margin-top: 0; }
.sched-item {
  display: grid; grid-template-columns: 72px 4px 1fr; align-items: center; gap: 0.7rem;
  padding: 0.4rem 0; border-top: 1px solid var(--bg-soft); min-width: 0; max-width: 100%;
}
.sched-time { font-size: 0.8rem; font-weight: 700; color: var(--ink); text-align: right; white-space: nowrap; }
.sched-bar { width: 4px; align-self: stretch; border-radius: 3px; min-height: 20px; }
.sched-body { display: flex; flex-direction: column; min-width: 0; max-width: 100%; }
.sched-title { font-size: 0.9rem; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; word-break: break-word; }
.sched-sub {
  font-size: 0.75rem; color: var(--muted); line-height: 1.35;
  display: -webkit-box; overflow: hidden; overflow-wrap: anywhere; word-break: break-word;
  -webkit-box-orient: vertical; -webkit-line-clamp: 2;
}
.sched-empty { color: var(--muted); font-size: 0.88rem; padding: 0.4rem 0; line-height: 1.5; }
.sched-connect { display: inline-block; margin-top: 0.6rem; }

/* ---------- App launcher grid ---------- */
.apps-head { margin-bottom: 0.9rem; }
.apps-head h3 { margin: 0; font-size: 1.05rem; font-weight: 800; letter-spacing: -0.01em; }
.apps-head p { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.88rem; }
.app-grid {
  display: grid; gap: 0.7rem;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
}
.app-cell { position: relative; }
.app-tile {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 0.5rem;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 1.1rem 0.8rem 0.9rem; text-decoration: none; color: inherit; height: 100%;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.app-tile:hover {
  transform: translateY(-3px); box-shadow: var(--shadow);
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
}
.app-ic {
  width: 48px; height: 48px; border-radius: 13px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 12%, #fff);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line));
}
.app-ic .tile-icon-svg { width: 24px; height: 24px; }
.app-name { font-weight: 700; font-size: 0.9rem; line-height: 1.25; }
.app-kind {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); opacity: 0.85;
}
.app-tile:hover .app-kind { color: var(--accent); }
.cred-mini {
  position: absolute; top: 0.45rem; right: 0.45rem; margin: 0; padding: 0;
  width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center;
  border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 0.78rem; line-height: 1;
}
.cred-mini:hover { border-color: var(--brand); }

/* ---------- Tiles: credentials ---------- */
.tile-wrap { position: relative; display: flex; flex-direction: column; }
.cred-btn {
  align-self: flex-start; margin-top: 0.4rem; padding: 0.25rem 0.6rem;
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700; color: var(--muted); cursor: pointer; font-family: inherit;
}
.cred-btn:hover { color: var(--brand-ink); border-color: var(--brand); }

.cred-popover {
  position: absolute; z-index: 40; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow); padding: 0.8rem; min-width: 240px;
}
.cred-head { font-weight: 700; font-size: 0.85rem; margin-bottom: 0.5rem; }
.cred-row { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.4rem; }
.cred-label { font-size: 0.7rem; font-weight: 700; color: var(--muted); width: 34px; }
.cred-value {
  flex: 1; background: var(--bg-soft); padding: 0.25rem 0.5rem; border-radius: 7px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis;
}
.cred-copy {
  border: 1px solid var(--line); background: #fff; border-radius: 7px; padding: 0.25rem 0.55rem;
  font-size: 0.72rem; font-weight: 700; cursor: pointer; color: var(--brand-ink); font-family: inherit;
}
.cred-open { display: inline-block; margin-top: 0.35rem; font-size: 0.8rem; color: var(--brand-ink); font-weight: 700; text-decoration: none; }

/* ---------- Buttons + tool actions ---------- */
.tool-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 0.9rem; }
.btn-primary {
  padding: 0.6rem 1rem; border: none; border-radius: 10px; background: var(--brand);
  color: #fff; font-weight: 700; cursor: pointer; font-family: inherit; font-size: 0.9rem; text-decoration: none;
}
.btn-primary:hover { background: var(--brand-ink); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-secondary {
  padding: 0.6rem 1rem; border: 1px solid var(--line); border-radius: 10px; background: #fff;
  color: var(--ink); font-weight: 700; cursor: pointer; font-family: inherit; font-size: 0.9rem; text-decoration: none;
}
.btn-secondary:hover { border-color: var(--brand); color: var(--brand-ink); }
.btn-ghost {
  padding: 0.6rem 0.9rem; border: none; border-radius: 10px; background: transparent;
  color: var(--muted); font-weight: 700; cursor: pointer; font-family: inherit; font-size: 0.9rem;
}
.btn-ghost:hover { color: #c0392b; }

/* ---------- Google Calendar connection bar ---------- */
.gcal-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  flex-wrap: wrap; margin-bottom: 0.8rem;
}
.gcal-status { display: flex; align-items: center; gap: 0.55rem; font-size: 0.92rem; }
.gcal-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.gcal-dot.on { background: #22a06b; box-shadow: 0 0 0 3px color-mix(in srgb, #22a06b 20%, transparent); }
.gcal-dot.off { background: var(--muted); box-shadow: 0 0 0 3px color-mix(in srgb, var(--muted) 18%, transparent); }
.gcal-actions { display: flex; align-items: center; gap: 0.4rem; }
.gcal-disconnect { margin: 0; display: inline; }
.gcal-note { margin: 0 0 1.2rem; color: var(--muted); font-size: 0.84rem; }

/* ---------- Add-a-skill ---------- */
.skill-new { margin-bottom: 1.6rem; }
.skill-new > summary {
  cursor: pointer; font-weight: 700; color: var(--brand-ink); display: inline-block;
  padding: 0.5rem 0.9rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; list-style: none;
}
.skill-new > summary::-webkit-details-marker { display: none; }
.skill-form { display: grid; gap: 0.7rem; max-width: 640px; margin-top: 1rem; }
.skill-form label { display: grid; gap: 0.3rem; font-size: 0.8rem; font-weight: 700; color: var(--muted); }
.skill-form input, .skill-form textarea {
  padding: 0.6rem 0.75rem; border: 1px solid var(--line); border-radius: 10px;
  font-size: 0.92rem; font-family: inherit; background: #fff; color: var(--ink); resize: vertical;
}
.skill-form textarea { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.85rem; }
.skill-form input:focus, .skill-form textarea:focus { outline: 2px solid var(--brand); border-color: var(--brand); }
.skill-form button {
  justify-self: start; padding: 0.6rem 1.2rem; border: none; border-radius: 10px;
  background: var(--brand); color: #fff; font-weight: 700; cursor: pointer; font-family: inherit;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 1.4rem; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 0.6rem 1.1rem; border-radius: 999px;
  font-size: 0.85rem; font-weight: 600; z-index: 60; box-shadow: var(--shadow);
}

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: static; flex-direction: row;
    align-items: center; justify-content: space-between; padding: 0.9rem 1.1rem;
  }
  .side-nav { margin-top: 0; flex-direction: row; align-items: center; gap: 0.5rem; }
  .side-nav-main { grid-auto-flow: column; }
  .side-nav-bottom { border-top: none; padding-top: 0; margin-top: 0; grid-auto-flow: column; align-items: center; }
  .container, .page-head { padding-left: 1.1rem; padding-right: 1.1rem; }
}
