/* =============================================================================
   Genysis IQ - client dashboard
   Extends the public site's design system (styles.css). Load styles.css first.
   ============================================================================= */

:root {
  --ok: #4fb286;
  --ok-soft: #a8dcc4;
  --warn: #d8a657;
  --warn-soft: #edd3a4;
  --err: #c9566f;
  --err-soft: #e6a3b1;
  --sidebar-w: 248px;
}

/* An explicit `display` on a component beats the browser's [hidden] rule, so
   anything hidden in markup would still render. Settle it once, globally. */
[hidden] { display: none !important; }

/* These layouts are column-order dependent, and grid follows writing
   direction. Some browser extensions flip the document to RTL after load,
   which silently swaps the two columns. Pin the direction so it cannot. */
.auth-body,
.app { direction: ltr; }

/* Belt and braces: place both columns explicitly rather than relying on DOM
   order. Extensions that reorder nodes or inject `order` cannot swap them. */
.auth-aside { grid-area: 1 / 1; }
.auth-main  { grid-area: 1 / 2; }
.auth-aside, .auth-main { order: 0 !important; }

/* ============================================================ auth pages == */

.auth-body {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
}

/* On a wide screen each column owns its own scroll. Without this, a short
   window makes the tall brand panel stretch the page and pushes the sign-in
   button below the fold. */
@media (min-width: 1025px) {
  .auth-body { height: 100vh; overflow: hidden; }
  .auth-aside,
  .auth-main { max-height: 100vh; overflow-y: auto; overscroll-behavior: contain; }
}

.auth-aside {
  position: relative;
  overflow: hidden;
  padding: clamp(36px, 5vw, 64px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-right: 1px solid var(--line);
  background: linear-gradient(160deg, #060d1e 0%, #04060c 70%);
}

.auth-aside::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--grid);
  mask-image: radial-gradient(120% 90% at 20% 10%, #000, transparent 70%);
  -webkit-mask-image: radial-gradient(120% 90% at 20% 10%, #000, transparent 70%);
}

.auth-aside::after {
  content: "";
  position: absolute;
  top: -25%;
  left: -15%;
  width: 70%;
  height: 90%;
  background: radial-gradient(closest-side, rgba(59, 111, 224, 0.22), transparent);
  pointer-events: none;
}

.auth-aside > * { position: relative; z-index: 2; }

.auth-aside .brand img { width: 232px; }

.auth-pitch { max-width: 30ch; }
.auth-pitch h1 { margin: 22px 0 20px; font-size: clamp(2.1rem, 3.4vw, 3.1rem); }
.auth-pitch p { color: var(--muted); margin: 0; font-size: 1.02rem; }

.auth-points {
  list-style: none;
  margin: 34px 0 0;
  padding: 0;
  display: grid;
  gap: 2px;
  border-top: 1px solid var(--line);
}

.auth-points li {
  display: flex;
  gap: 13px;
  align-items: flex-start;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14.5px;
  color: #c6d4e9;
}

.auth-points svg { width: 17px; height: 17px; flex: none; margin-top: 3px; color: var(--blue-bright); }

.auth-foot {
  font-size: 12.5px;
  color: var(--faint);
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}
.auth-foot a:hover { color: var(--text); }

.auth-main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(32px, 5vw, 56px) clamp(20px, 4vw, 48px);
}

.auth-card { width: 100%; max-width: 452px; }

.auth-card > header { margin-bottom: 26px; }
.auth-card h2 {
  font-family: var(--serif);
  font-size: clamp(1.8rem, 2.8vw, 2.3rem);
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 12px 0 8px;
}
.auth-card > header p { color: var(--muted); margin: 0; font-size: 15px; }

/* ---------------------------------------------------------------- tabs -- */

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.02);
  margin-bottom: 30px;
}

.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 11px 16px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.3s var(--ease), color 0.3s var(--ease);
}

.tab[aria-selected="true"] {
  background: linear-gradient(135deg, var(--blue) 0%, #2a52b8 100%);
  color: #fff;
}

.tab:not([aria-selected="true"]):hover { color: var(--text); }

.auth-panel[hidden] { display: none; }

/* --------------------------------------------------------------- forms -- */

.stack { display: grid; gap: 20px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

.field-hint { font-size: 12px; color: var(--faint); }

.field-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.field-row a { font-size: 12px; color: var(--blue-soft); }
.field-row a:hover { color: #fff; }

.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 56px; }

.pw-toggle {
  position: absolute;
  right: 0;
  top: 8px;
  border: 0;
  background: none;
  color: var(--faint);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 4px 2px;
}
.pw-toggle:hover { color: var(--blue-soft); }

/* password strength */
.pw-meter { display: grid; gap: 7px; margin-top: 2px; }
.pw-bars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.pw-bars i {
  height: 3px;
  border-radius: 2px;
  background: rgba(125, 158, 210, 0.18);
  transition: background 0.3s var(--ease);
}
.pw-meter[data-score="1"] .pw-bars i:nth-child(-n + 1) { background: var(--err); }
.pw-meter[data-score="2"] .pw-bars i:nth-child(-n + 2) { background: var(--warn); }
.pw-meter[data-score="3"] .pw-bars i:nth-child(-n + 3) { background: #6fa8dc; }
.pw-meter[data-score="4"] .pw-bars i { background: var(--ok); }
.pw-note { font-size: 11.5px; color: var(--faint); }

.check {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  font-size: 13.5px;
  color: var(--muted);
  cursor: pointer;
}
.check input { margin: 2px 0 0; accent-color: var(--blue); width: 16px; height: 16px; flex: none; }
.check a { color: var(--blue-soft); }

.auth-alt {
  margin: 24px 0 0;
  font-size: 14px;
  color: var(--muted);
  text-align: center;
}
.auth-alt button {
  border: 0;
  background: none;
  color: var(--blue-soft);
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
  padding: 0;
}
.auth-alt button:hover { color: #fff; }

/* --------------------------------------------------------------- alerts -- */

.alert {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, 0.02);
  font-size: 14px;
  line-height: 1.55;
  color: var(--muted);
}

.alert svg { width: 17px; height: 17px; flex: none; margin-top: 2px; }
.alert strong { display: block; color: var(--text); font-weight: 600; margin-bottom: 3px; }
.alert a { color: var(--blue-soft); text-decoration: underline; }
.alert button.linklike {
  border: 0; background: none; padding: 0; cursor: pointer;
  color: var(--blue-soft); text-decoration: underline; font: inherit;
}

.alert--ok { border-color: rgba(79, 178, 134, 0.42); color: var(--ok-soft); }
.alert--ok svg, .alert--ok strong { color: var(--ok); }
.alert--warn { border-color: rgba(216, 166, 87, 0.42); color: var(--warn-soft); }
.alert--warn svg, .alert--warn strong { color: var(--warn); }
.alert--err { border-color: rgba(201, 86, 111, 0.45); color: var(--err-soft); }
.alert--err svg, .alert--err strong { color: var(--err); }
.alert[hidden] { display: none; }

/* ======================================================= dashboard shell == */

.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.app-side {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 26px 18px;
  border-right: 1px solid var(--line);
  background: #050810;
}

.app-side .brand { padding: 0 8px 8px; }
.app-side .brand img { width: 178px; }

.side-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 20px 10px 8px;
}

.side-nav { display: grid; gap: 2px; }

.side-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: var(--radius);
  font-size: 14.5px;
  color: var(--muted);
  transition: background 0.25s var(--ease), color 0.25s var(--ease);
}

.side-nav a svg { width: 17px; height: 17px; flex: none; }
.side-nav a:hover { background: rgba(255, 255, 255, 0.04); color: var(--text); }

.side-nav a.is-active {
  background: rgba(59, 111, 224, 0.14);
  color: #fff;
  box-shadow: inset 2px 0 0 var(--blue-bright);
}

.side-foot { margin-top: auto; padding-top: 18px; border-top: 1px solid var(--line); }

.side-user { display: flex; align-items: center; gap: 11px; padding: 10px 8px; }

.avatar {
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--blue), #22407e);
}

.side-user div { min-width: 0; }
.side-user b {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.side-user span {
  display: block;
  font-size: 11.5px;
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.side-signout {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: border-color 0.25s var(--ease), color 0.25s var(--ease);
}
.side-signout svg { width: 16px; height: 16px; }
.side-signout:hover { border-color: var(--line-3); color: var(--text); }

/* -------------------------------------------------------------- content -- */

.app-main { min-width: 0; display: flex; flex-direction: column; }

/* Fixed at every width so it never occupies a grid cell of .app - in flow it
   would push .app-main out of the second column. */
.app-scrim {
  position: fixed;
  inset: 0;
  z-index: 110;
  background: rgba(2, 4, 9, 0.7);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s var(--ease);
}

@media (min-width: 901px) { .app-scrim { display: none; } }

.app-top {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px clamp(20px, 3.4vw, 42px);
  border-bottom: 1px solid var(--line);
  background: rgba(4, 6, 12, 0.9);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.app-top h1 {
  font-family: var(--serif);
  font-size: clamp(1.45rem, 2.2vw, 1.95rem);
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.app-top p { margin: 4px 0 0; font-size: 13.5px; color: var(--faint); }

.app-content {
  padding: clamp(24px, 3.2vw, 40px) clamp(20px, 3.4vw, 42px) 64px;
  display: grid;
  gap: 22px;
  align-content: start;
  max-width: 1180px;
}

.app-burger {
  display: none;
  width: 42px; height: 42px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  position: relative;
}
.app-burger span {
  position: absolute; left: 12px; width: 18px; height: 1.5px; background: var(--text);
}
.app-burger span:nth-child(1) { top: 15px; }
.app-burger span:nth-child(2) { top: 20px; }
.app-burger span:nth-child(3) { top: 25px; }

/* ---------------------------------------------------------------- cards -- */

.card-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

.tile {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--surface), #05090f);
  padding: 22px 24px;
}

.tile-label {
  display: block;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--faint);
}

.tile-value {
  display: block;
  font-family: var(--serif);
  font-size: 2.1rem;
  line-height: 1.1;
  margin-top: 10px;
  color: #fff;
}

.tile-note { font-size: 13px; color: var(--muted); margin-top: 6px; }

.panel-block {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--surface), #05090f);
  overflow: hidden;
}

.panel-block > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 20px clamp(20px, 2.6vw, 28px);
  border-bottom: 1px solid var(--line);
}

.panel-block > header h2 { font-size: 1.05rem; font-weight: 600; letter-spacing: -0.01em; }
.panel-block > header p { margin: 4px 0 0; font-size: 13px; color: var(--faint); }
.panel-body { padding: clamp(20px, 2.6vw, 28px); }

/* --------------------------------------------------------------- badges -- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  color: var(--muted);
  white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--ok { color: var(--ok-soft); border-color: rgba(79, 178, 134, 0.4); }
.badge--warn { color: var(--warn-soft); border-color: rgba(216, 166, 87, 0.4); }
.badge--err { color: var(--err-soft); border-color: rgba(201, 86, 111, 0.4); }

/* ------------------------------------------------------------ data list -- */

.data-list { display: grid; }
.data-list > div {
  display: grid;
  grid-template-columns: 210px 1fr;
  gap: 20px;
  padding: 15px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14.5px;
}
.data-list > div:last-child { border-bottom: 0; padding-bottom: 0; }
.data-list dt { color: var(--faint); font-size: 12.5px; letter-spacing: 0.04em; }
.data-list dd { margin: 0; color: var(--text); word-break: break-word; }
.data-list dd.muted { color: var(--faint); }

/* ---------------------------------------------------------- empty state -- */

.empty {
  text-align: center;
  padding: clamp(34px, 5vw, 56px) 24px;
  display: grid;
  justify-items: center;
  gap: 14px;
}

.empty-icon {
  width: 54px; height: 54px;
  display: grid; place-items: center;
  border: 1px solid var(--line-2);
  border-radius: 14px;
  color: var(--blue-bright);
  background: rgba(59, 111, 224, 0.06);
}
.empty-icon svg { width: 24px; height: 24px; }
.empty h3 { font-size: 1.1rem; font-weight: 600; }
.empty p { margin: 0; max-width: 46ch; color: var(--muted); font-size: 14.5px; }

/* ------------------------------------------------------------- skeleton -- */

.skeleton {
  border-radius: 6px;
  background: linear-gradient(90deg, rgba(125,158,210,.07) 25%, rgba(125,158,210,.15) 37%, rgba(125,158,210,.07) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
  color: transparent !important;
}
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* --------------------------------------------------------- misc helpers -- */

.inline-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.muted-note { font-size: 13px; color: var(--faint); margin: 0; }
.btn-sm { padding: 10px 18px; font-size: 13px; }
.btn-danger { border-color: rgba(201, 86, 111, 0.45); color: var(--err-soft); }
.btn-danger:hover { border-color: var(--err); background: rgba(201, 86, 111, 0.1); }
.spinner {
  width: 15px; height: 15px; flex: none;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------- responsive -- */

@media (max-width: 1000px) {
  .card-grid { grid-template-columns: 1fr 1fr; }
}

/* Auth stacks earlier than the dashboard does - two columns get cramped
   before a sidebar plus content does. */
@media (max-width: 1024px) {
  .auth-body { grid-template-columns: 1fr; }
  .auth-aside { grid-area: 1 / 1; }
  .auth-main  { grid-area: 2 / 1; }
  .auth-aside {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 28px 24px;
  }
  .auth-pitch, .auth-points, .auth-foot { display: none; }
  .auth-main { padding: 40px 24px 56px; }
}

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .app-side {
    position: fixed;
    inset: 0 auto 0 0;
    width: 272px;
    z-index: 120;
    transform: translateX(-100%);
    transition: transform 0.4s var(--ease);
  }
  .app-side.is-open { transform: none; }
  .app-burger { display: block; }
  .app-scrim.is-open { opacity: 1; pointer-events: auto; }
}

@media (max-width: 640px) {
  .row-2 { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: 1fr; }
  .data-list > div { grid-template-columns: 1fr; gap: 5px; }
  .app-top { padding: 16px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton, .spinner { animation: none; }
}

/* ============================================================== AI chat === */

.chat {
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: 0;
  height: calc(100vh - 190px);
  min-height: 460px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--surface), #05090f);
  overflow: hidden;
}

/* ------------------------------------------------------ conversation list -- */

.chat-list {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  min-height: 0;
  background: rgba(4, 7, 14, 0.5);
}

.chat-list header {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line);
}

.chat-new {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 11px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line-2);
  background: rgba(59, 111, 224, 0.1);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.25s var(--ease), background 0.25s var(--ease);
}
.chat-new svg { width: 15px; height: 15px; }
.chat-new:hover { border-color: var(--blue-bright); background: rgba(59, 111, 224, 0.2); }

.chat-threads { flex: 1; overflow-y: auto; padding: 8px; display: grid; gap: 2px; align-content: start; }

.chat-thread {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13.5px;
  line-height: 1.35;
  display: grid;
  gap: 3px;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.chat-thread b { font-weight: 500; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-thread span { font-size: 11px; color: var(--faint); }
.chat-thread:hover { background: rgba(255, 255, 255, 0.04); color: var(--text); }
.chat-thread.is-active { background: rgba(59, 111, 224, 0.16); color: #fff; }
.chat-empty-note { padding: 18px 14px; font-size: 13px; color: var(--faint); }

/* --------------------------------------------------------------- messages -- */

.chat-main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: clamp(18px, 2.4vw, 30px);
  display: flex;
  flex-direction: column;
  gap: 20px;
  overscroll-behavior: contain;
}

.msg { display: flex; gap: 13px; max-width: 760px; }
.msg-avatar {
  width: 30px; height: 30px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 10.5px; font-weight: 600; color: #fff;
}
.msg-user .msg-avatar { background: linear-gradient(135deg, #3d4a63, #232c3d); }
.msg-ai .msg-avatar { background: linear-gradient(135deg, var(--blue), #22407e); }

.msg-body { min-width: 0; padding-top: 4px; }
.msg-who {
  font-size: 11px; font-weight: 600; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--faint); margin-bottom: 7px;
}
.msg-text {
  font-size: 15px; line-height: 1.68; color: #dbe4f2;
  white-space: pre-wrap; word-break: break-word;
}
.msg-ai .msg-text { color: var(--text); }
.msg-error .msg-text { color: var(--err-soft); }

/* typing indicator */
.msg-typing span {
  display: inline-block; width: 6px; height: 6px; margin-right: 4px;
  border-radius: 50%; background: var(--blue-soft);
  animation: blink 1.2s ease-in-out infinite;
}
.msg-typing span:nth-child(2) { animation-delay: 0.18s; }
.msg-typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.25; } 30% { opacity: 1; } }

/* ------------------------------------------------------------- composer --- */

.chat-composer { border-top: 1px solid var(--line); padding: 14px clamp(18px, 2.4vw, 30px) 18px; }

.composer-box {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.02);
  padding: 8px 8px 8px 16px;
  transition: border-color 0.25s var(--ease);
}
.composer-box:focus-within { border-color: var(--blue-bright); }

.composer-box textarea {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  line-height: 1.55;
  resize: none;
  outline: none;
  max-height: 168px;
  padding: 8px 0;
  min-height: 24px;
}
.composer-box textarea::placeholder { color: #445573; }

.composer-send {
  flex: none;
  width: 40px; height: 40px;
  border: 0;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--blue), #2a52b8);
  color: #fff;
  cursor: pointer;
  display: grid; place-items: center;
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
}
.composer-send svg { width: 17px; height: 17px; }
.composer-send:hover:not(:disabled) { transform: translateY(-1px); }
.composer-send:disabled { opacity: 0.4; cursor: not-allowed; }

.composer-note {
  margin: 9px 2px 0;
  font-size: 11.5px;
  color: var(--faint);
  display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap;
}

@media (max-width: 900px) {
  .chat { grid-template-columns: 1fr; height: auto; }
  .chat-list { border-right: 0; border-bottom: 1px solid var(--line); }
  .chat-threads { max-height: 168px; }
  .chat-log { min-height: 340px; max-height: 55vh; }
}

@media (prefers-reduced-motion: reduce) {
  .msg-typing span { animation: none; opacity: 0.6; }
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ========================================================= admin console == */

.admin-row {
  display: grid;
  grid-template-columns: 1.6fr 1fr 0.9fr auto;
  gap: 18px;
  align-items: center;
  padding: 15px 0;
  border-bottom: 1px solid var(--line);
}
.admin-row:last-child { border-bottom: 0; }

.admin-co b { display: block; font-size: 15px; font-weight: 600; }
.admin-co small { display: block; font-size: 12.5px; color: var(--faint); margin-top: 2px; }
.admin-meta { font-size: 13px; color: var(--muted); }
.admin-meta small { display: block; font-size: 11.5px; color: var(--faint); margin-top: 4px; }

.admin-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.btn-approve {
  padding: 9px 16px;
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid rgba(79, 178, 134, 0.45);
  border-radius: 999px;
  background: rgba(79, 178, 134, 0.12);
  color: var(--ok-soft);
  cursor: pointer;
  transition: background 0.25s var(--ease), border-color 0.25s var(--ease);
}
.btn-approve:hover { background: rgba(79, 178, 134, 0.25); border-color: var(--ok); }
.btn-approve:disabled { opacity: 0.5; cursor: default; }

/* ------------------------------------------------------------- drawer ---- */

.drawer-scrim {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(2, 4, 9, 0.72);
  backdrop-filter: blur(2px);
}

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  z-index: 310;
  width: min(560px, 100%);
  display: flex;
  flex-direction: column;
  background: #070c18;
  border-left: 1px solid var(--line-2);
  box-shadow: -30px 0 60px -20px rgba(0, 0, 0, 0.8);
}

.drawer > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 26px;
  border-bottom: 1px solid var(--line);
}
.drawer > header h2 {
  font-family: var(--serif);
  font-size: 1.6rem;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.drawer-close {
  border: 0; background: none; color: var(--faint);
  font-size: 30px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.drawer-close:hover { color: var(--text); }

.drawer-body { flex: 1; overflow-y: auto; padding: 26px; overscroll-behavior: contain; }

.drawer select,
.drawer textarea,
.drawer input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  font: inherit;
  font-size: 14.5px;
  outline: none;
  transition: border-color 0.25s var(--ease);
}
.drawer textarea { line-height: 1.6; resize: vertical; font-size: 14px; }
.drawer select:focus,
.drawer textarea:focus,
.drawer input:focus { border-color: var(--blue-bright); }

.drawer .field-hint { line-height: 1.5; }
.drawer .linklike {
  border: 0; background: none; padding: 0; cursor: pointer;
  color: var(--blue-soft); text-decoration: underline; font: inherit; font-size: 12px;
}

.test-out {
  margin-top: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.02);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
}
.test-out b {
  display: block;
  font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--faint); margin-bottom: 8px;
}

@media (max-width: 760px) {
  .admin-row { grid-template-columns: 1fr; gap: 10px; }
  .admin-actions { justify-content: flex-start; }
}

/* ====================================================== markdown replies == */

.msg-text.md { color: var(--text); }
.msg-text.md > *:first-child { margin-top: 0; }
.msg-text.md > *:last-child { margin-bottom: 0; }

.md p { margin: 0 0 12px; line-height: 1.68; }

.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 {
  font-family: var(--sans);
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.3;
  margin: 22px 0 10px;
  color: #fff;
}
.md h1 { font-size: 1.32rem; }
.md h2 { font-size: 1.19rem; }
.md h3 { font-size: 1.07rem; }
.md h4, .md h5, .md h6 { font-size: 1rem; }
.md h1, .md h2 { padding-bottom: 8px; border-bottom: 1px solid var(--line); }

.md strong, .md b { font-weight: 600; color: #fff; }
.md em, .md i { font-style: italic; }
.md del, .md s { opacity: 0.6; }
.md mark { background: rgba(92, 141, 255, 0.25); color: #fff; padding: 0 3px; border-radius: 2px; }

.md a { color: var(--blue-soft); text-decoration: underline; text-underline-offset: 2px; }
.md a:hover { color: #fff; }

.md ul, .md ol { margin: 0 0 12px; padding-left: 22px; }
.md li { margin: 5px 0; line-height: 1.62; }
.md li::marker { color: var(--blue-soft); }
.md ul ul, .md ol ol, .md ul ol, .md ol ul { margin: 5px 0 0; }

.md blockquote {
  margin: 0 0 12px;
  padding: 2px 0 2px 16px;
  border-left: 2px solid var(--blue);
  color: var(--muted);
}
.md blockquote p:last-child { margin-bottom: 0; }

.md hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

/* ---------------------------------------------------------- inline code -- */

.md code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.875em;
  background: rgba(125, 158, 210, 0.13);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1.5px 5px;
  color: #cfe0ff;
  word-break: break-word;
}

/* ----------------------------------------------------------- code blocks -- */

.md pre {
  position: relative;
  margin: 0 0 14px;
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-lg);
  background: #05080f;
  overflow: hidden;
}

.md pre code {
  display: block;
  padding: 14px 16px;
  overflow-x: auto;
  background: none;
  border: 0;
  border-radius: 0;
  color: #d7e2f4;
  font-size: 13px;
  line-height: 1.62;
  white-space: pre;
  word-break: normal;
  tab-size: 2;
}

.code-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px 8px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
}
.code-bar > span {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}

.code-copy {
  border: 1px solid var(--line-2);
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease);
}
.code-copy:hover { border-color: var(--blue-bright); color: #fff; }

/* ---------------------------------------------------------------- tables -- */

.table-wrap {
  overflow-x: auto;
  margin: 0 0 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-lg);
  overscroll-behavior-x: contain;
}

.md table { border-collapse: collapse; width: 100%; font-size: 14px; }
.md thead { background: rgba(125, 158, 210, 0.08); }
.md th, .md td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  vertical-align: top;
}
.md th:last-child, .md td:last-child { border-right: 0; }
.md tbody tr:last-child td { border-bottom: 0; }
.md th { font-weight: 600; color: #fff; white-space: nowrap; }
.md tbody tr:hover { background: rgba(255, 255, 255, 0.02); }

/* --------------------------------------------------------- streaming caret */

.md.is-streaming > *:last-child::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 2px;
  vertical-align: text-bottom;
  background: var(--blue-bright);
  animation: caret 1s steps(2) infinite;
}
@keyframes caret { 50% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .md.is-streaming > *:last-child::after { animation: none; }
}

@media (max-width: 640px) {
  .md pre code { font-size: 12px; }
  .md table { font-size: 13px; }
  .md th, .md td { padding: 8px 11px; }
}

/* ======================================================== file depot ===== */

.dropzone {
  display: grid;
  justify-items: center;
  gap: 9px;
  padding: clamp(28px, 4vw, 46px) 24px;
  border: 1.5px dashed var(--line-3);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(59, 111, 224, 0.04), transparent);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.25s var(--ease), background 0.25s var(--ease), transform 0.25s var(--ease);
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--blue-bright); background: rgba(59, 111, 224, 0.08); }
.dropzone.is-over { border-color: var(--blue-bright); background: rgba(59, 111, 224, 0.14); transform: scale(1.005); }

.dropzone-icon {
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line-2);
  background: rgba(59, 111, 224, 0.08);
  color: var(--blue-bright);
}
.dropzone-icon svg { width: 21px; height: 21px; }
.dropzone b { font-size: 15px; font-weight: 500; }
.dz-link { color: var(--blue-soft); text-decoration: underline; }
.dz-note { font-size: 12.5px; color: var(--faint); }

/* ------------------------------------------------------------ upload queue */

.upload-queue { display: grid; gap: 8px; margin-top: 14px; }

.upload-row {
  display: grid;
  grid-template-columns: 1fr 140px 46px;
  gap: 14px;
  align-items: center;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.upload-info { min-width: 0; }
.upload-info b { display: block; font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-info small { display: block; font-size: 11.5px; color: var(--faint); margin-top: 2px; }
.upload-err { color: var(--err-soft) !important; }

.upload-bar { height: 4px; border-radius: 3px; background: rgba(125, 158, 210, 0.16); overflow: hidden; }
.upload-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--blue), var(--blue-bright)); transition: width 0.2s linear; }
.upload-pct { font-size: 11.5px; font-weight: 600; color: var(--muted); text-align: right; }

.upload-row.is-done { border-color: rgba(79, 178, 134, 0.4); }
.upload-row.is-done .upload-bar i { background: var(--ok); width: 100% !important; }
.upload-row.is-done .upload-pct { color: var(--ok-soft); }
.upload-row.is-failed { border-color: rgba(201, 86, 111, 0.45); }
.upload-row.is-failed .upload-pct { color: var(--err-soft); }

/* -------------------------------------------------------------- file list */

.file-list { display: grid; }

.file-row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.file-row:last-child { border-bottom: 0; }
.file-row:hover { background: rgba(255, 255, 255, 0.015); }

.file-icon {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: var(--radius);
  border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, 0.02);
  color: var(--muted);
}
.file-icon svg { width: 19px; height: 19px; }
.file-image  { color: #7fd1a8; }
.file-pdf    { color: #e08a9c; }
.file-sheet  { color: #7fd1a8; }
.file-doc    { color: var(--blue-soft); }
.file-archive{ color: var(--warn-soft); }
.file-video  { color: #c4a5f0; }
.file-audio  { color: #f0c6a5; }
.file-code   { color: var(--blue-bright); }

.file-name { min-width: 0; }
.file-name b { display: block; font-size: 14.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-name small { display: block; font-size: 12px; color: var(--faint); margin-top: 2px; }

.file-actions { display: flex; gap: 6px; }

.icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease), background 0.2s var(--ease);
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { border-color: var(--blue-bright); color: #fff; background: rgba(59, 111, 224, 0.1); }
.icon-btn:disabled { opacity: 0.45; cursor: default; }
.icon-danger:hover { border-color: var(--err); color: var(--err-soft); background: rgba(201, 86, 111, 0.1); }

/* ======================================================== settings rows == */

.setting {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}
.setting:first-child { padding-top: 0; }
.setting:last-child { border-bottom: 0; padding-bottom: 0; }

.setting-copy { max-width: 60ch; }
.setting-copy b { display: block; font-size: 14.5px; font-weight: 600; margin-bottom: 5px; }
.setting-copy span { font-size: 13.5px; color: var(--muted); line-height: 1.6; }

/* toggle */
.switch { position: relative; flex: none; cursor: pointer; display: inline-flex; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch-track {
  width: 46px; height: 26px;
  border-radius: 999px;
  background: rgba(125, 158, 210, 0.18);
  border: 1px solid var(--line-2);
  display: block;
  transition: background 0.25s var(--ease), border-color 0.25s var(--ease);
}
.switch-thumb {
  position: absolute; top: 4px; left: 4px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #93a5c2;
  transition: transform 0.25s var(--ease), background 0.25s var(--ease);
}
.switch input:checked + .switch-track { background: var(--blue); border-color: var(--blue-bright); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(20px); background: #fff; }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--blue-bright); outline-offset: 3px; }

/* ====================================================== idle warning ===== */

.idle-shade {
  position: fixed; inset: 0; z-index: 500;
  display: grid; place-items: center;
  padding: 24px;
  background: rgba(2, 4, 9, 0.82);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.idle-box {
  width: 100%; max-width: 420px;
  display: grid; justify-items: center; gap: 12px;
  text-align: center;
  padding: 34px 30px 30px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, #0a1020, #05080f);
  box-shadow: 0 40px 80px -30px rgba(0, 0, 0, 0.9);
}

.idle-icon {
  width: 50px; height: 50px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(216, 166, 87, 0.4);
  background: rgba(216, 166, 87, 0.1);
  color: var(--warn);
}
.idle-icon svg { width: 24px; height: 24px; }

.idle-box h2 {
  font-family: var(--serif);
  font-size: 1.7rem;
  letter-spacing: -0.02em;
}
.idle-box p { margin: 0; font-size: 14.5px; color: var(--muted); line-height: 1.6; }
.idle-box p b { color: var(--warn-soft); font-variant-numeric: tabular-nums; }

.idle-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }

/* ---------------------------------------------------------- responsive -- */

@media (max-width: 640px) {
  .upload-row { grid-template-columns: 1fr 70px; row-gap: 8px; }
  .upload-bar { grid-column: 1 / -1; order: 3; }
  .file-row { grid-template-columns: 34px 1fr; row-gap: 8px; }
  .file-actions { grid-column: 2; justify-content: flex-start; }
  .file-icon { width: 34px; height: 34px; }
  .setting { flex-direction: column; gap: 14px; }
  .idle-box { padding: 28px 22px 24px; }
  .idle-actions { width: 100%; }
  .idle-actions .btn { flex: 1; justify-content: center; }
}

@media (max-width: 640px) {
  /* The subtitle wraps to three lines on a phone and crowds the burger. */
  .app-top p { display: none; }
  .app-top h1 { font-size: 1.25rem; }
}

/* ============================================ chat: delete + copy ======== */

.chat-clear {
  width: 100%;
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--faint);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease), background 0.2s var(--ease);
}
.chat-clear svg { width: 14px; height: 14px; }
.chat-clear:hover {
  border-color: rgba(201, 86, 111, 0.45);
  color: var(--err-soft);
  background: rgba(201, 86, 111, 0.08);
}

/* --------------------------------------------------------- thread rows -- */

.chat-thread-row {
  position: relative;
  display: flex;
  align-items: stretch;
  border-radius: var(--radius);
  transition: background 0.2s var(--ease);
}
.chat-thread-row:hover { background: rgba(255, 255, 255, 0.04); }
.chat-thread-row.is-active { background: rgba(59, 111, 224, 0.16); }
.chat-thread-row.is-active .chat-thread { color: #fff; }

.chat-thread-row .chat-thread { flex: 1; min-width: 0; background: none; }
.chat-thread-row .chat-thread:hover { background: none; }

.thread-del {
  flex: none;
  width: 30px;
  margin: 4px 4px 4px 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--faint);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s var(--ease), color 0.2s var(--ease), background 0.2s var(--ease);
}
.thread-del svg { width: 15px; height: 15px; }
.chat-thread-row:hover .thread-del,
.thread-del:focus-visible { opacity: 1; }
.thread-del:hover { color: var(--err-soft); background: rgba(201, 86, 111, 0.14); }

/* Touch devices have no hover, so never hide the control there. */
@media (hover: none) {
  .thread-del { opacity: 1; }
}

/* ------------------------------------------------------------ toolbar --- */

.chat-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px clamp(18px, 2.4vw, 30px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.015);
}

.chat-toolbar-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.chat-toolbar-actions { display: flex; gap: 8px; flex: none; }

.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease), background 0.2s var(--ease);
}
.chip-btn svg { width: 14px; height: 14px; }
.chip-btn:hover { border-color: var(--blue-bright); color: #fff; background: rgba(59, 111, 224, 0.1); }
.chip-btn.is-copied { border-color: rgba(79, 178, 134, 0.5); color: var(--ok-soft); }
.chip-danger:hover { border-color: var(--err); color: var(--err-soft); background: rgba(201, 86, 111, 0.1); }

/* -------------------------------------------------- per-message actions -- */

.msg-tools {
  margin-top: 9px;
  opacity: 0;
  transition: opacity 0.2s var(--ease);
}
.msg:hover .msg-tools,
.msg-tools:focus-within { opacity: 1; }

.msg-copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--faint);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease);
}
.msg-copy svg { width: 13px; height: 13px; }
.msg-copy:hover { border-color: var(--blue-bright); color: var(--text); }
.msg-copy.is-copied { border-color: rgba(79, 178, 134, 0.5); color: var(--ok-soft); }

@media (hover: none) {
  .msg-tools { opacity: 1; }
}

@media (max-width: 640px) {
  .chat-toolbar { padding: 10px 18px; }
  .chat-toolbar-title { display: none; }
  .chat-toolbar-actions { width: 100%; }
  .chip-btn { flex: 1; justify-content: center; }
}

/* ================================================= file depot terms ====== */

.terms-shade {
  position: fixed;
  inset: 0;
  z-index: 600;
  display: grid;
  place-items: center;
  padding: clamp(12px, 3vw, 32px);
  background: rgba(2, 4, 9, 0.88);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.terms-box {
  width: 100%;
  max-width: 660px;
  max-height: min(88vh, 780px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, #0a1020, #05080f);
  box-shadow: 0 50px 100px -35px rgba(0, 0, 0, 0.95);
  overflow: hidden;
}

.terms-box > header {
  display: flex;
  align-items: flex-start;
  gap: 15px;
  padding: 24px clamp(20px, 3vw, 30px) 18px;
  border-bottom: 1px solid var(--line);
}
.terms-box > header h2 {
  font-family: var(--serif);
  font-size: 1.65rem;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.terms-box > header p { margin: 5px 0 0; font-size: 13.5px; color: var(--muted); }

.terms-icon {
  flex: none;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(216, 166, 87, 0.42);
  background: rgba(216, 166, 87, 0.1);
  color: var(--warn);
}
.terms-icon svg { width: 22px; height: 22px; }

/* ----------------------------------------------------------- the terms -- */

.terms-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 22px clamp(20px, 3vw, 30px);
  font-size: 14.5px;
  line-height: 1.68;
  color: var(--muted);
}
.terms-body:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--blue-bright); }

.terms-body h3 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #fff;
  margin: 22px 0 8px;
}
.terms-body h3:first-child { margin-top: 0; }
.terms-body p { margin: 0 0 12px; }
.terms-body b { color: var(--text); font-weight: 600; }

.terms-body ul { margin: 0 0 14px; padding-left: 20px; }
.terms-body li { margin: 6px 0; }
.terms-body li::marker { color: var(--warn); }

.terms-end {
  margin-top: 18px !important;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--faint);
}

/* how far through the reader is */
.terms-progress {
  height: 2px;
  background: rgba(125, 158, 210, 0.14);
  flex: none;
}
.terms-progress i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--blue), var(--blue-bright));
  transition: width 0.12s linear;
}

/* -------------------------------------------------------------- footer -- */

.terms-box > footer {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px clamp(20px, 3vw, 30px) 20px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.015);
}

.terms-hint { margin: 0; font-size: 12.5px; color: var(--faint); }
.terms-hint.is-ready { color: var(--ok-soft); }

.terms-actions { display: flex; align-items: center; gap: 10px; }

#termsAccept:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
#termsAccept:disabled::before { opacity: 0; }

/* ------------------------------------------- the blue loading ring ------ */

.terms-spinner { display: flex; align-items: center; gap: 12px; }
.terms-spinner span { font-size: 13.5px; font-weight: 500; color: var(--blue-soft); }

.terms-spinner svg {
  width: 34px; height: 34px;
  transform: rotate(-90deg);   /* start the sweep at 12 o'clock */
  flex: none;
}
.terms-spinner circle { fill: none; stroke-width: 4; stroke-linecap: round; }
.ring-track { stroke: rgba(125, 158, 210, 0.2); }
.ring-fill {
  stroke: var(--blue-bright);
  stroke-dasharray: 125.6;      /* 2 * PI * r, r = 20 */
  stroke-dashoffset: 125.6;
  transition: stroke-dashoffset 0.12s linear;
  filter: drop-shadow(0 0 5px rgba(92, 141, 255, 0.55));
}

@media (max-width: 640px) {
  .terms-box { max-height: 92vh; }
  .terms-box > header { padding: 18px 18px 14px; }
  .terms-box > header h2 { font-size: 1.35rem; }
  .terms-body { padding: 18px; font-size: 14px; }
  .terms-box > footer { padding: 14px 18px 18px; }
  .terms-actions { width: 100%; }
  .terms-actions .btn { flex: 1; justify-content: center; }
  .terms-spinner { width: 100%; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  .ring-fill, .terms-progress i { transition: none; }
}

/* ============================================== build-your-assistant ===== */

.gpt-box { max-width: 620px; }
.gpt-icon {
  border-color: rgba(92, 141, 255, 0.42);
  background: rgba(59, 111, 224, 0.12);
  color: var(--blue-bright);
}

.gpt-body { display: grid; gap: 0; }
.gpt-step { display: grid; gap: 18px; }

.gpt-body .field label { color: var(--text); font-size: 12px; }

.gpt-body input,
.gpt-body textarea,
.gpt-body select {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  font: inherit;
  font-size: 14.5px;
  outline: none;
  transition: border-color 0.25s var(--ease);
}
.gpt-body textarea { line-height: 1.6; resize: vertical; }
.gpt-body input:focus,
.gpt-body textarea:focus,
.gpt-body select:focus { border-color: var(--blue-bright); }
.gpt-body input::placeholder,
.gpt-body textarea::placeholder { color: #445573; }

.gpt-advanced-toggle {
  justify-self: start;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  color: var(--blue-soft);
  text-decoration: underline;
  font: inherit;
  font-size: 12.5px;
}
.gpt-advanced-toggle:hover { color: #fff; }

.gpt-preview {
  display: block;
  margin-top: 6px;
  font-style: italic;
  color: var(--text);
  line-height: 1.6;
}

#gptAlert { margin-bottom: 18px; }

@media (max-width: 640px) {
  .gpt-step { gap: 15px; }
}

/* ------------------------------------------------------- admin toast ---- */

.admin-toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 400;
  max-width: min(460px, calc(100% - 32px));
  padding: 13px 20px;
  border: 1px solid rgba(79, 178, 134, 0.42);
  border-radius: 999px;
  background: rgba(10, 20, 16, 0.96);
  color: var(--ok-soft);
  font-size: 13.5px;
  box-shadow: 0 20px 45px -18px rgba(0, 0, 0, 0.9);
  transition: opacity 0.4s var(--ease), transform 0.4s var(--ease);
}
.admin-toast.is-out { opacity: 0; transform: translateX(-50%) translateY(8px); }

/* Shown on the typing indicator while a rate-limited request is retried. */
.msg-busy {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--warn-soft);
}
.msg-busy::before {
  content: "";
  width: 12px; height: 12px;
  border: 2px solid rgba(216, 166, 87, 0.3);
  border-top-color: var(--warn);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@media (prefers-reduced-motion: reduce) { .msg-busy::before { animation: none; } }

/* Shown in place of the dropzone when uploading has not been granted. */
.upload-locked {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 20px 24px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-lg);
  background: rgba(216, 166, 87, 0.05);
}
.upload-locked > div { flex: 1; min-width: 220px; }
.upload-locked b { display: block; font-size: 14.5px; font-weight: 600; margin-bottom: 4px; }
.upload-locked span { font-size: 13.5px; color: var(--muted); line-height: 1.55; }

.upload-locked-icon {
  flex: none;
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(216, 166, 87, 0.4);
  background: rgba(216, 166, 87, 0.1);
  color: var(--warn);
}
.upload-locked-icon svg { width: 20px; height: 20px; }

@media (max-width: 640px) {
  .upload-locked { padding: 18px; }
  .upload-locked .btn { width: 100%; justify-content: center; }
}

/* =============================================================================
   Website traffic
   ============================================================================= */

.an-head {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

/* the "n on the site right now" badge -------------------------------------- */
.an-live {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 15px;
  border-radius: 100px;
  border: 1px solid rgba(74, 124, 232, 0.34);
  background: rgba(74, 124, 232, 0.1);
  font-size: 13px;
  color: var(--muted);
}
.an-live b { color: var(--text); font-size: 15px; font-variant-numeric: tabular-nums; }
.an-live.is-quiet { border-color: var(--line-2); background: rgba(255, 255, 255, 0.02); }
.an-live.is-quiet .live-pip { background: var(--faint); animation: none; box-shadow: none; }

.live-pip {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: #4ad07a;
  box-shadow: 0 0 0 0 rgba(74, 208, 122, 0.55);
  animation: pip 2.2s var(--ease) infinite;
}
@keyframes pip {
  0%   { box-shadow: 0 0 0 0 rgba(74, 208, 122, 0.5); }
  70%  { box-shadow: 0 0 0 9px rgba(74, 208, 122, 0); }
  100% { box-shadow: 0 0 0 0 rgba(74, 208, 122, 0); }
}
/* the dot on the sidebar link, so staff see activity from any view */
.side-nav a .live-pip { margin-left: auto; }

@media (prefers-reduced-motion: reduce) {
  .live-pip { animation: none; }
}

/* range switch -------------------------------------------------------------- */
.an-range {
  display: inline-flex;
  border: 1px solid var(--line-2);
  border-radius: 4px;
  overflow: hidden;
}
.an-range button {
  appearance: none;
  border: 0;
  border-right: 1px solid var(--line-2);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.an-range button:last-child { border-right: 0; }
.an-range button:hover { background: rgba(255, 255, 255, 0.04); color: var(--text); }
.an-range button.is-on { background: var(--blue); color: #fff; }

.an-stamp {
  margin-left: auto;
  font-size: 12px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.an-tiles { margin-bottom: 22px; }

/* two panels side by side --------------------------------------------------- */
.an-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}
.an-split > * { min-width: 0; }   /* or a wide table stretches its column */

/* chart --------------------------------------------------------------------- */
.an-chart { min-height: 220px; }
.an-chart svg { width: 100%; height: 220px; display: block; }
.an-chart .k-views    { fill: var(--blue); }
.an-chart .k-visitors { fill: rgba(126, 168, 245, 0.42); }
.an-chart .an-grid    { stroke: var(--line); stroke-width: 1; }
.an-chart .an-axis    { fill: var(--faint); font-size: 10px; font-family: inherit; }
.an-bar-g:hover .k-views    { fill: #6f9bf0; }
.an-bar-g:hover .k-visitors { fill: rgba(160, 192, 250, 0.6); }

.an-legend {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--faint);
}
.an-legend i {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
  margin-left: 8px;
}
.an-legend i.k-views    { background: var(--blue); }
.an-legend i.k-visitors { background: rgba(126, 168, 245, 0.42); }

/* tables -------------------------------------------------------------------- */
.an-table-wrap { overflow-x: auto; }    /* never let a table push the page wide */

.an-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.an-table th,
.an-table td {
  text-align: left;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.an-table thead th {
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 500;
  border-bottom-color: var(--line-2);
  white-space: nowrap;
}
.an-table tbody tr:last-child td { border-bottom: 0; }
.an-table tbody tr:hover { background: rgba(255, 255, 255, 0.018); }
.an-table .n { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.an-table .n b { color: var(--text); font-weight: 600; }
.an-table .n small { display: block; color: var(--faint); font-size: 11px; }

/* first cell: rank, name, path, and a bar showing relative volume */
.an-table td:first-child { position: relative; padding-left: 12px; }

.an-rank {
  display: inline-block;
  width: 20px;
  color: var(--faint);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  vertical-align: top;
  padding-top: 2px;
}
.an-page {
  display: inline-block;
  max-width: 100%;
  vertical-align: top;
}
.an-page b {
  display: block;
  color: var(--text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 34ch;
}
.an-page small {
  display: block;
  color: var(--faint);
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 34ch;
}
/* Sits behind the text, so the row reads as a bar chart without a second column. */
.an-bar {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  width: var(--w, 0%);
  background: linear-gradient(90deg, var(--blue), rgba(74, 124, 232, 0.25));
  border-radius: 0 2px 2px 0;
  pointer-events: none;
}

/* kind pills ---------------------------------------------------------------- */
.an-kind {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 100px;
  font-size: 11px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  border: 1px solid var(--line-2);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.02);
}
.an-kind.k-cta      { border-color: rgba(74, 124, 232, 0.4);  color: #9ab8f5; background: rgba(74, 124, 232, 0.1); }
.an-kind.k-call,
.an-kind.k-email,
.an-kind.k-form     { border-color: rgba(74, 208, 122, 0.36); color: #7fd8a2; background: rgba(74, 208, 122, 0.09); }
.an-kind.k-outbound { border-color: rgba(224, 168, 92, 0.36); color: #e0b978; background: rgba(224, 168, 92, 0.08); }
.an-kind.k-new      { border-color: rgba(74, 208, 122, 0.45); color: #7fd8a2; background: rgba(74, 208, 122, 0.12); }

/* live feed ----------------------------------------------------------------- */
.an-feed {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 420px;
  overflow-y: auto;
}
.an-feed li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 2px;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
  color: var(--muted);
}
.an-feed li:last-child { border-bottom: 0; }
.an-feed li > span:first-child {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.an-feed b { color: var(--text); font-weight: 500; }
.an-feed time {
  color: var(--faint);
  font-size: 11.5px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
/* a new arrival flashes once, then settles */
.an-feed li.is-fresh { animation: feedIn 1.6s var(--ease); }
@keyframes feedIn {
  0%   { background: rgba(74, 124, 232, 0.16); }
  100% { background: transparent; }
}
@media (prefers-reduced-motion: reduce) {
  .an-feed li.is-fresh { animation: none; }
}

/* device meters ------------------------------------------------------------- */
.an-devices {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.an-device {
  display: grid;
  grid-template-columns: 68px 1fr 40px;
  align-items: center;
  gap: 12px;
  font-size: 12.5px;
  color: var(--muted);
}
.an-device b { color: var(--text); font-weight: 500; text-transform: capitalize; }
.an-device > span:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.an-meter {
  height: 6px;
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.05);
  overflow: hidden;
}
.an-meter i {
  display: block;
  height: 100%;
  border-radius: 100px;
  background: var(--blue);
  transition: width 0.5s var(--ease);
}

/* ---------------------------------------------------------------- narrow --- */
@media (max-width: 1100px) {
  .an-split { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .an-head { gap: 10px; }
  .an-stamp { margin-left: 0; width: 100%; }
  .an-range { width: 100%; }
  .an-range button { flex: 1; padding: 9px 6px; }
  .an-table { font-size: 12.5px; }
  .an-table th, .an-table td { padding: 9px 8px; }
  .an-page b, .an-page small { max-width: 20ch; }
  .an-rank { display: none; }
  .an-chart svg { height: 180px; }
  .an-feed { max-height: 320px; }
}

/* "on Contact" trailing the feed line - present but not competing */
.an-feed .an-on { color: var(--faint); }
