/* ============================================================
   OfficeAI — Vercel Design System implementation
   Canvas #ffffff · Text #171717 · Geist typography
   Shadow-as-border (never solid borders on cards/inputs)
   ============================================================ */

:root {
  /* Palette */
  --ds-gray-100: #f2f2f2;
  --ds-gray-200: #e5e5e5;
  --ds-gray-300: #cccccc;
  --ds-gray-400: #999999;
  --ds-gray-500: #666666;
  --ds-gray-600: #444444;
  --ds-gray-900: #171717;
  --ds-gray-1000: #0a0a0a;
  --ds-canvas: #ffffff;
  --ds-background-hover: rgba(0, 0, 0, 0.04);
  --ds-blue-600: #0068d6;
  --ds-blue-700: #0057bd;
  --ds-amber-700: #b45309;
  --ds-red-600: #dc2626;
  --ds-green-700: #15803d;

  /* Shadow-as-border tokens */
  --ds-shadow-border:
    0 0 0 1px rgba(0, 0, 0, 0.08),
    0 2px 2px rgba(0, 0, 0, 0.04);
  --ds-shadow-border-hover:
    0 0 0 1px rgba(0, 0, 0, 0.12),
    0 2px 4px rgba(0, 0, 0, 0.06);
  --ds-shadow-border-active:
    0 0 0 1px rgba(0, 0, 0, 0.16),
    0 4px 8px rgba(0, 0, 0, 0.08);
  --ds-shadow-input:
    0 0 0 1px rgba(0, 0, 0, 0.08);
  --ds-shadow-input-focus:
    0 0 0 2px var(--ds-gray-900);

  /* Typography */
  --font-sans: "Geist", "GeistSans", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Geist Mono", "GeistMono", ui-monospace, SFMono-Regular, Menlo,
    Monaco, Consolas, monospace;

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-16: 64px;

  color-scheme: light;
}

/* ------------------------------------------------------------
   Reset & base
   ------------------------------------------------------------ */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--ds-canvas);
  color: var(--ds-gray-900);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  letter-spacing: -0.02em;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.04em; /* ~-2.4px at heading sizes */
  line-height: 1.15;
  text-wrap: balance;
}

h1 { font-size: clamp(40px, 7vw, 64px); }
h2 { font-size: clamp(26px, 4vw, 36px); }
h3 { font-size: 20px; letter-spacing: -0.03em; }

p { margin: 0; }

a {
  color: inherit;
  text-decoration: none;
}
a:hover { color: var(--ds-gray-500); }

code, pre, .mono {
  font-family: var(--font-mono);
  letter-spacing: 0;
}

img, svg { display: block; max-width: 100%; }

/* Focus rings — never remove outlines */
:focus-visible {
  outline: 2px solid var(--ds-gray-900);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

::selection {
  background: var(--ds-gray-900);
  color: #ffffff;
}

/* ------------------------------------------------------------
   Layout
   ------------------------------------------------------------ */
.container {
  width: 100%;
  max-width: 1080px;
  margin-inline: auto;
  padding-inline: var(--space-6);
}

.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) 0;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.nav__brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 600;
  letter-spacing: -0.04em;
  font-size: 16px;
}

.nav__brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--ds-gray-900);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
}

.section {
  padding-block: var(--space-16);
}

.hero {
  padding-block: calc(var(--space-16) + var(--space-4)) var(--space-10);
  text-align: center;
}

.hero p.lede {
  margin: var(--space-4) auto 0;
  max-width: 560px;
  font-size: 18px;
  color: var(--ds-gray-500);
  text-wrap: pretty;
}

.hero__actions {
  margin-top: var(--space-8);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px 10px;
  border-radius: 999px;
  box-shadow: var(--ds-shadow-border);
  font-size: 12px;
  font-weight: 500;
  color: var(--ds-gray-500);
  background: var(--ds-canvas);
}

.badge__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ds-green-700);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-4);
}

/* ------------------------------------------------------------
   Cards — shadow-as-border, no solid CSS borders
   ------------------------------------------------------------ */
.card {
  background: var(--ds-canvas);
  border-radius: var(--radius-lg);
  box-shadow: var(--ds-shadow-border);
  padding: var(--space-5);
  transition: box-shadow 150ms ease;
}

.card--hover:hover {
  box-shadow: var(--ds-shadow-border-hover);
}

.card__title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 600;
  font-size: 14px;
  margin-bottom: var(--space-2);
}

.card__meta {
  color: var(--ds-gray-500);
  font-size: 13px;
}

/* ------------------------------------------------------------
   Buttons — always <button type="button|submit">
   ------------------------------------------------------------ */
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 8px 16px;
  min-height: 36px;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--ds-gray-100);
  color: var(--ds-gray-900);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: background-color 120ms ease, box-shadow 120ms ease, transform 60ms ease;
  user-select: none;
}

.btn:hover { background: var(--ds-background-hover); }
.btn:active { transform: translateY(0.5px); }
.btn[disabled],
.btn[aria-busy="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--ds-gray-900);
  color: #ffffff;
}
.btn--primary:hover { background: var(--ds-gray-1000); }

.btn--outline {
  background: var(--ds-canvas);
  box-shadow: var(--ds-shadow-border);
}
.btn--outline:hover {
  box-shadow: var(--ds-shadow-border-hover);
  background: var(--ds-canvas);
}

.btn--lg {
  padding: 12px 20px;
  min-height: 44px;
  font-size: 15px;
  border-radius: 10px;
}

/* Spinner shown while submitting (aria-busy="true") */
.btn .spinner {
  display: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  animation: ds-spin 0.6s linear infinite;
}
.btn[aria-busy="true"] .spinner { display: inline-block; }

@keyframes ds-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ------------------------------------------------------------
   Forms — labels explicit, inputs ≥16px, ellipsis placeholders
   ------------------------------------------------------------ */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.label {
  font-size: 13px;
  font-weight: 500;
  color: var(--ds-gray-600);
}

.input,
.textarea {
  appearance: none;
  width: 100%;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 16px;          /* prevents mobile zoom */
  line-height: 1.5;
  color: var(--ds-gray-900);
  background: var(--ds-canvas);
  border: 0;                 /* shadow-as-border instead */
  border-radius: var(--radius-md);
  box-shadow: var(--ds-shadow-input);
  transition: box-shadow 120ms ease;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--ds-gray-400);
}

.textarea { resize: vertical; min-height: 88px; }

.input:hover,
.textarea:hover { box-shadow: var(--ds-shadow-border-hover); }

.input:focus-visible,
.textarea:focus-visible {
  outline: none;             /* replaced with visible ring below */
  box-shadow: var(--ds-shadow-input-focus);
}

.input[aria-invalid="true"],
.textarea[aria-invalid="true"] {
  box-shadow: 0 0 0 2px var(--ds-red-600);
}

.field__error {
  display: none;
  font-size: 13px;
  color: var(--ds-red-600);
}
.field.has-error .field__error { display: block; }

.hint {
  font-size: 12px;
  color: var(--ds-gray-400);
}

/* ------------------------------------------------------------
   Dashboard
   ------------------------------------------------------------ */
.dash-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  padding-block: var(--space-8) var(--space-6);
}

.tabs {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border-radius: var(--radius-md);
  background: var(--ds-gray-100);
}

.tab {
  padding: 6px 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--ds-gray-500);
  cursor: pointer;
  transition: color 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
}
.tab:hover { color: var(--ds-gray-900); }

.tab[aria-selected="true"] {
  background: var(--ds-canvas);
  color: var(--ds-gray-900);
  box-shadow: var(--ds-shadow-border);
}

.dash-grid {
  display: grid;
  grid-template-columns: minmax(320px, 380px) 1fr;
  gap: var(--space-5);
  align-items: start;
  padding-bottom: var(--space-16);
}

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

/* Activity feed / terminal log */
.feed {
  margin: 0;
  padding: var(--space-4);
  list-style: none;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.7;
  max-height: 520px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.feed li {
  display: flex;
  gap: var(--space-2);
  padding-block: 2px;
  animation: feed-in 180ms ease both;
}

@keyframes feed-in {
  from { opacity: 0; transform: translateY(3px); }
  to   { opacity: 1; transform: none; }
}

.feed__time {
  flex: none;
  color: var(--ds-gray-400);
  white-space: nowrap;
}

.feed__channel {
  flex: none;
  min-width: 52px;
  font-weight: 600;
  white-space: nowrap;
}

.ch-ceo       { color: var(--ds-gray-900); }
.ch-cto       { color: var(--ds-blue-600); }
.ch-cmo       { color: #9333ea; }
.ch-cfo       { color: var(--ds-amber-700); }
.ch-coo       { color: var(--ds-green-700); }
.ch-support   { color: #0891b2; }
.ch-system    { color: var(--ds-gray-500); }

.lv-error  { color: var(--ds-red-600); }
.lv-warn   { color: var(--ds-amber-700); }
.lv-success{ color: var(--ds-green-700); }
.lv-debug  { color: var(--ds-gray-400); }

.feed__msg { overflow-wrap: anywhere; }

.feed-empty {
  color: var(--ds-gray-400);
  font-style: italic;
}

.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ds-green-700);
  animation: pulse 1.6s ease-in-out infinite;
}
.live-dot[data-idle="true"] { background: var(--ds-gray-300); animation: none; }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.45; transform: scale(0.85); }
}

/* Sub-task pipeline */
.pipeline {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.subtask {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  box-shadow: var(--ds-shadow-border);
  font-size: 13px;
}

.subtask__status {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ds-gray-300);
}
.subtask[data-status="in_progress"]     .subtask__status { background: var(--ds-blue-600); animation: pulse 1.4s ease-in-out infinite; }
.subtask[data-status="awaiting_review"] .subtask__status { background: var(--ds-amber-700); }
.subtask[data-status="approved"]        .subtask__status { background: var(--ds-green-700); }
.subtask[data-status="rejected"]        .subtask__status,
.subtask[data-status="failed"]          .subtask__status { background: var(--ds-red-600); }

.subtask__role {
  flex: none;
  font-weight: 600;
  min-width: 148px;
}

.subtask__title {
  flex: 1;
  color: var(--ds-gray-600);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pill {
  flex: none;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: uppercase;
  color: var(--ds-gray-500);
  background: var(--ds-gray-100);
}
.pill[data-tone="ok"]   { color: var(--ds-green-700); background: #ecfdf5; }
.pill[data-tone="busy"] { color: var(--ds-blue-600); background: #eff6ff; }
.pill[data-tone="warn"] { color: var(--ds-amber-700); background: #fffbeb; }
.pill[data-tone="bad"]  { color: var(--ds-red-600); background: #fef2f2; }

/* Agent toggle chip (skills & resources pages) */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 6px;
  border-radius: var(--radius-md);
  background: var(--ds-gray-100);
  font-size: 13px;
  color: var(--ds-gray-700);
  cursor: pointer;
  transition: background-color 120ms ease, box-shadow 120ms ease;
}
.chip:hover { background: var(--ds-gray-200); }
.chip input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--ds-gray-900);
}
.chip input:checked + .nav__brand-mark { box-shadow: 0 0 0 1px var(--ds-gray-900); }
.chip input:disabled { cursor: not-allowed; opacity: 0.6; }


/* Result viewer */
.result {
  font-size: 14px;
}

.result pre {
  margin: var(--space-3) 0;
  padding: var(--space-4);
  border-radius: var(--radius-md);
  background: var(--ds-gray-1000);
  color: #ededed;
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.6;
}

.result table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-block: var(--space-3);
}
.result th, .result td {
  padding: 6px 10px;
  text-align: left;
}
.result thead tr { box-shadow: var(--ds-shadow-border); }
.result tbody tr { box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.06); }

.skeleton-line {
  height: 12px;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--ds-gray-100) 25%, var(--ds-gray-200) 50%, var(--ds-gray-100) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite linear;
  margin-block: 10px;
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* Task history list */
.task-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  text-align: left;
  padding: var(--space-3) var(--space-4);
  border: 0;
  background: transparent;
  border-radius: var(--radius-md);
  font: inherit;
  cursor: pointer;
  transition: background-color 120ms ease;
}
.task-row:hover { background: var(--ds-background-hover); }

.task-row__id {
  flex: none;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ds-gray-400);
}

.task-row__title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.divider {
  height: 1px;
  margin-block: var(--space-4);
  background: transparent;
  box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.06);
}

.footer {
  padding-block: var(--space-8);
  color: var(--ds-gray-400);
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.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;
}
