/* Parcle Console — design tokens + base styles */

:root,
[data-theme="light"] {
  --bg: #FAFAF9;
  --surface: #FFFFFF;
  --surface-raised: #FFFFFF;
  --border-subtle: #ECECEA;
  --border: #DEDEDA;
  --border-strong: #C9C9C4;
  --text-primary: #0A0A0B;
  --text-secondary: #6B6B70;
  --text-tertiary: #9A9AA0;
  --hover: #F4F4F2;
  --selected: #EFEFEC;

  --success: #12A150;
  --success-bg: #E8F6EE;
  --warning: #C98A00;
  --warning-bg: #FBF2DC;
  --error: #D93036;
  --error-bg: #FBE9EA;
  --info: #2E7CF6;
  --info-bg: #E6EFFD;

  --shadow-1: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.06);
  --shadow-2: 0 2px 4px rgba(0,0,0,.04), 0 24px 48px rgba(0,0,0,.12);

  /* accent: violet (default) */
  --accent: #5B4FFF;
  --accent-hover: #4A3EE8;
  --accent-muted: #EEEBFF;
  --accent-text: #3A2FCC;
  --on-accent: #FFFFFF;
}

[data-theme="dark"] {
  --bg: #0A0A0B;
  --surface: #111113;
  --surface-raised: #16161A;
  --border-subtle: #1F1F23;
  --border: #2A2A2F;
  --border-strong: #3A3A40;
  --text-primary: #F5F5F4;
  --text-secondary: #A1A1A6;
  --text-tertiary: #6B6B70;
  --hover: #1A1A1E;
  --selected: #222226;

  --success: #2DD17A;
  --success-bg: #0E2A1C;
  --warning: #F5C24A;
  --warning-bg: #2E2413;
  --error: #F06262;
  --error-bg: #2A1316;
  --info: #6EA8FF;
  --info-bg: #132038;

  --shadow-1: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.4);
  --shadow-2: 0 2px 4px rgba(0,0,0,.3), 0 24px 48px rgba(0,0,0,.6);

  --accent: #7D73FF;
  --accent-hover: #9089FF;
  --accent-muted: #1A1735;
  --accent-text: #B3ACFF;
  --on-accent: #0A0A0B;
}

[data-accent="sulfur"][data-theme="light"] {
  --accent: #A88600;
  --accent-hover: #8C6F00;
  --accent-muted: #FBF2CB;
  --accent-text: #6B5500;
  --on-accent: #0A0A0B;
}
[data-accent="sulfur"][data-theme="dark"] {
  --accent: #E5C200;
  --accent-hover: #F0D033;
  --accent-muted: #2B2410;
  --accent-text: #F0D84A;
  --on-accent: #0A0A0B;
}
[data-accent="teal"][data-theme="light"] {
  --accent: #0F766E;
  --accent-hover: #0A5A54;
  --accent-muted: #DEF0ED;
  --accent-text: #0A5A54;
  --on-accent: #FFFFFF;
}
[data-accent="teal"][data-theme="dark"] {
  --accent: #2DD4BF;
  --accent-hover: #5EE0CE;
  --accent-muted: #0F2B27;
  --accent-text: #7EE7D8;
  --on-accent: #0A0A0B;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  line-height: 22px;
  font-weight: 400;
  color: var(--text-primary);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01", "cv11";
}

.mono {
  font-family: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, Monaco, 'Cascadia Code', monospace;
  font-size: 13px;
  line-height: 20px;
  letter-spacing: -0.01em;
}
.mono-sm { font-size: 12px; line-height: 16px; }

button { font-family: inherit; cursor: pointer; border: none; background: none; padding: 0; color: inherit; }
input, select, textarea { font-family: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

/* Type scale */
.t-display-xl { font-size: 48px; line-height: 56px; font-weight: 500; letter-spacing: -0.02em; }
.t-display    { font-size: 32px; line-height: 40px; font-weight: 500; letter-spacing: -0.02em; }
.t-h1         { font-size: 24px; line-height: 32px; font-weight: 500; letter-spacing: -0.015em; }
.t-h2         { font-size: 18px; line-height: 28px; font-weight: 500; letter-spacing: -0.01em; }
.t-h3         { font-size: 15px; line-height: 24px; font-weight: 500; letter-spacing: -0.005em; }
.t-body       { font-size: 14px; line-height: 22px; font-weight: 400; }
.t-small      { font-size: 13px; line-height: 20px; font-weight: 400; }
.t-micro      { font-size: 11px; line-height: 16px; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; }

.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-accent { color: var(--accent-text); }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* Chips */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px; height: 22px;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  font-size: 12px; line-height: 16px; font-weight: 500;
  background: var(--surface);
  color: var(--text-secondary);
  white-space: nowrap;
}
.chip.success { color: var(--success); background: var(--success-bg); border-color: transparent; }
.chip.warning { color: var(--warning); background: var(--warning-bg); border-color: transparent; }
.chip.error   { color: var(--error);   background: var(--error-bg);   border-color: transparent; }
.chip.info    { color: var(--info);    background: var(--info-bg);    border-color: transparent; }
.chip.accent  { color: var(--accent-text); background: var(--accent-muted); border-color: transparent; }
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px;
  border-radius: 8px;
  font-size: 13px; font-weight: 500; line-height: 1;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  transition: background 80ms, border-color 80ms, color 80ms;
  white-space: nowrap;
}
.btn:hover { background: var(--hover); }
.btn.primary {
  background: var(--text-primary); color: var(--bg);
  border-color: var(--text-primary);
}
.btn.primary:hover { background: var(--text-primary); opacity: 0.88; }
.btn.accent { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn.accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-secondary); }
.btn.ghost:hover { background: var(--hover); color: var(--text-primary); }
.btn.danger { color: #DC2626; }
.btn.danger:hover { background: rgba(220, 38, 38, 0.08); border-color: #DC2626; color: #DC2626; }
.btn.sm { height: 26px; padding: 0 8px; font-size: 12px; border-radius: 6px; }
.btn.lg { height: 40px; padding: 0 16px; font-size: 14px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* Cards / surfaces */
.card {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
}

/* Inputs */
.input {
  height: 34px; padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 80ms, box-shadow 80ms;
  width: 100%;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-muted); }
.input::placeholder { color: var(--text-tertiary); }

/* Responsive topbar */
.topbar-search { min-width: 240px; }
@media (max-width: 1100px) {
  .topbar-ticker-wrap { display: none; }
}
@media (max-width: 860px) {
  .topbar-search { min-width: 140px; }
}

/* Segmented */
.segmented {
  display: inline-flex; padding: 3px;
  background: var(--hover); border-radius: 8px;
  gap: 2px;
}
.segmented button {
  height: 26px; padding: 0 12px;
  font-size: 12px; font-weight: 500;
  border-radius: 6px;
  color: var(--text-secondary);
}
.segmented button.active {
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}

/* Pulse */
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}
.pulse { animation: pulse-dot 1.6s cubic-bezier(.4,0,.6,1) infinite; }

/* Shimmer/skeleton */
@keyframes shimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--border-subtle) 0%, var(--hover) 50%, var(--border-subtle) 100%);
  background-size: 800px 100%;
  animation: shimmer 1.6s linear infinite;
  border-radius: 6px;
}

/* Transient toast entrance (bottom-anchored: fade + slide up) */
@keyframes parcle-toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Learned-concept graph reveal: whole-graph entrance morph, the reveal card
   pop-in, and the reloading spinner. */
@keyframes parcle-graph-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes parcle-reveal-pop {
  from { opacity: 0; transform: scale(0.92) translateY(6px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes parcle-graph-spin {
  to { transform: rotate(360deg); }
}

/* Table */
table.parcle {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
table.parcle thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface);
  position: sticky; top: 0;
}
table.parcle tbody td {
  padding: 12px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}
table.parcle tbody tr:hover { background: var(--hover); cursor: pointer; }
table.parcle tbody tr:last-child td { border-bottom: none; }

/* Utility */
.row { display: flex; align-items: center; }
.col { display: flex; flex-direction: column; }
.gap-4 { gap: 4px; } .gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; }
.gap-16 { gap: 16px; } .gap-24 { gap: 24px; } .gap-32 { gap: 32px; }
.mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; } .mt-32 { margin-top: 32px; }

/* Kbd */
.kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface);
  font-family: 'Geist Mono', monospace;
  font-size: 10px;
  color: var(--text-secondary);
}

/* Focus visible */
*:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* Markdown — rendered assistant replies (chat bubbles, etc.) */
.md { font-size: 14px; line-height: 22px; color: var(--text-primary); word-wrap: break-word; }
.md > *:first-child { margin-top: 0; }
.md > *:last-child  { margin-bottom: 0; }
.md p  { margin: 0 0 8px; }
.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 {
  margin: 12px 0 6px; font-weight: 500; letter-spacing: -0.01em; line-height: 1.3;
}
.md h1 { font-size: 18px; }
.md h2 { font-size: 16px; }
.md h3 { font-size: 15px; }
.md h4, .md h5, .md h6 { font-size: 14px; }
.md ul, .md ol { margin: 4px 0 8px; padding-left: 20px; }
.md li { margin: 2px 0; }
.md li > p { margin: 0; }
.md code {
  font-family: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 12px;
  padding: 1px 5px;
  background: var(--hover);
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
}
.md pre {
  margin: 6px 0;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  overflow-x: auto;
  font-size: 12px;
  line-height: 18px;
}
.md pre code {
  padding: 0; background: transparent; border: 0; font-size: 12px;
  font-family: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}
.md a {
  color: var(--accent-text); text-decoration: underline; text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}
.md a:hover { text-decoration-thickness: 2px; }
.md blockquote {
  margin: 6px 0; padding: 4px 12px;
  border-left: 3px solid var(--border);
  color: var(--text-secondary);
}
.md hr { margin: 10px 0; border: 0; border-top: 1px solid var(--border-subtle); }
.md strong { font-weight: 600; }
.md em { font-style: italic; }
.md table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  margin: 8px 0; font-size: 13px;
  border: 1px solid var(--border-subtle);
  border-radius: 6px; overflow: hidden;
}
.md table th,
.md table td {
  padding: 6px 10px; text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}
.md table th {
  background: var(--hover); font-weight: 500;
  font-size: 11px; color: var(--text-tertiary);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.md table tr:last-child td { border-bottom: 0; }
.md table tbody tr:hover { background: var(--hover); }
.md img { max-width: 100%; border-radius: 6px; }

/* ── Auto-sync animation ─────────────────────────────────────────────────
   The first-run sync overlay: a central "My Cloud" orb pulses and emits
   skill tokens down beams into each agent node, which then resolve to a check. */
@keyframes parcle-as-overlay-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes parcle-as-pop {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes parcle-as-orb {
  0%, 100% { transform: scale(1);    box-shadow: 0 0 36px 4px var(--accent-muted); }
  50%      { transform: scale(1.06); box-shadow: 0 0 64px 16px var(--accent-muted); }
}
@keyframes parcle-as-ring {
  0%   { opacity: 0.55; transform: translate(-50%, -50%) scale(0.5); }
  100% { opacity: 0;    transform: translate(-50%, -50%) scale(2.6); }
}
@keyframes parcle-as-token {
  0%   { opacity: 0; transform: translateY(-4px) scale(0.7); }
  25%  { opacity: 1; transform: translateY(8px)  scale(1); }
  85%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(40px) scale(0.7); }
}
@keyframes parcle-as-beam {
  0%, 100% { opacity: 0.25; }
  50%      { opacity: 0.95; }
}
@keyframes parcle-as-check {
  from { opacity: 0; transform: scale(0.3); }
  60%  { transform: scale(1.18); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes parcle-as-spin { to { transform: rotate(360deg); } }
.parcle-as-orb   { animation: parcle-as-orb 1.8s ease-in-out infinite; }
.parcle-as-ring  { animation: parcle-as-ring 2.2s ease-out infinite; }
.parcle-as-token { animation: parcle-as-token 1.1s ease-in-out infinite; }
.parcle-as-beam  { animation: parcle-as-beam 1.1s ease-in-out infinite; }
.parcle-as-check { animation: parcle-as-check 0.4s cubic-bezier(.34,1.56,.64,1) both; }
.parcle-as-spin  { animation: parcle-as-spin 0.8s linear infinite; }
@media (prefers-reduced-motion: reduce) {
  .parcle-as-orb, .parcle-as-ring, .parcle-as-token, .parcle-as-beam, .parcle-as-spin, .parcle-as-check { animation: none; }
}

/* Auto-sync toggle switch — labeled iOS-style switch so its on/off state and
   "this is a toggle" affordance read at a glance. */
.as-switch {
  position: relative; display: inline-block; flex-shrink: 0; vertical-align: middle;
  width: 56px; height: 26px; border-radius: 999px;
  background: var(--border-strong);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.06);
  cursor: pointer; transition: background 160ms ease;
}
.as-switch[data-on="true"] { background: var(--accent); box-shadow: none; }
.as-switch[disabled] { opacity: 0.5; cursor: not-allowed; }
.as-switch .as-knob {
  position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.4);
  transition: left 180ms cubic-bezier(.34,1.4,.64,1);
}
.as-switch[data-on="true"] .as-knob { left: 33px; }
.as-switch .as-track-label {
  position: absolute; top: 0; height: 100%; right: 8px;
  display: flex; align-items: center;
  font-size: 9px; font-weight: 700; letter-spacing: .06em;
  color: var(--text-secondary); transition: color 160ms ease;
  pointer-events: none;
}
.as-switch[data-on="true"] .as-track-label { left: 9px; right: auto; color: var(--on-accent); }
