/* ============================================================================
   Krossings Content Engine — visual system v2 ("Studio")
   Complete rebuild: top-nav shell, split-screen auth, centered sheets,
   full-screen takeovers, staggered lists, motion everywhere (reduced-motion
   safe). Brand: platform-native — Tailwind grays, flat blue-600 (#2563eb), Jost,
   small radii, Lucide icons; matches the Kapps styleguide. Every class & id the
   app JS references is preserved.
   ========================================================================== */

:root {
  /* canvas + surfaces — platform grays (Tailwind scale, matches the Kapps styleguide) */
  --bg: #f9fafb;
  --bg-2: #ffffff;
  --card: #ffffff;
  --surface-2: #f3f4f6;   /* gray-100 */
  --surface-3: #e5e7eb;   /* gray-200 */

  /* lines */
  --border: #e5e7eb;         /* gray-200 */
  --border-strong: #d1d5db;  /* gray-300 */

  /* text — platform grays; --ink stays near-black for long-form reading surfaces */
  --text: #111827;   /* gray-900 */
  --muted: #6b7280;  /* gray-500 */
  --faint: #9ca3af;  /* gray-400 (decorative) */
  --ink: #1a1a1a;

  /* brand — flat blue-600 (platform-native; 5.17:1 on white, passes AA) */
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #2563eb;
  --accent-deep: #1e40af;
  --accent-grad: #2563eb;              /* flat now — kept as a var so existing refs resolve */
  --accent-glow: rgba(37,99,235,0);    /* glow retired (flat aesthetic) */
  --accent-tint: #eff6ff;              /* blue-50 */
  --accent-border: #bfdbfe;            /* blue-200 soft outline */

  /* status — 700 shades for AA on small pill/label text (emerald-600 was 3.6:1, fails) */
  --error: #dc2626;  /* red-600 */
  --ok: #047857;     /* emerald-700 (5.0:1) */
  --warn: #b45309;   /* amber-700 (4.6:1) */

  /* radii — small, shadcn-like */
  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 12px;

  /* shadows — layered low-alpha; --shadow-border is the shadow-as-border ring */
  --shadow: 0 1px 2px rgba(16,24,40,0.04), 0 1px 3px rgba(16,24,40,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(16,24,40,0.10), 0 4px 6px -4px rgba(16,24,40,0.08);
  --shadow-border: 0 0 0 1px rgba(16,24,40,0.06), 0 1px 2px -1px rgba(16,24,40,0.06), 0 2px 4px rgba(16,24,40,0.04);
  --ring: 0 0 0 3px rgba(37,99,235,0.20);

  --ease-out: cubic-bezier(.22,.9,.35,1);
  --ease-spring: cubic-bezier(.34,1.4,.44,1);
}

* { box-sizing: border-box; }
html { color-scheme: light; }

body {
  margin: 0;
  font-family: "Jost", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: rgba(37,99,235,0.18); }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: #c3ccdb transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: #cbd4e1; border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: #aab6c9; background-clip: padding-box; }

/* ---------------- utilities ---------------- */
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.spacer { flex: 1; }
.error { color: var(--error); }
.msg.ok { color: var(--ok); }
.msg.err { color: var(--error); }
.msg.inline { display: inline-block; margin-left: 0.75rem; }

h1, h2, h3, h4 { letter-spacing: -0.02em; }
h2 { margin-top: 0; }
a { color: var(--accent); }

/* ============================================================================
   MOTION LIBRARY
   ========================================================================== */
@keyframes fadeUp   { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn   { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheetIn  { from { opacity: 0; transform: translateY(26px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes popIn    { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: scale(1); } }
@keyframes takeoverIn { from { opacity: 0; transform: translateY(3vh); } to { opacity: 1; transform: none; } }
@keyframes spin     { to { transform: rotate(360deg); } }
@keyframes floaty   { 0% { transform: translate3d(0,0,0) scale(1); } 50% { transform: translate3d(24px,-30px,0) scale(1.08); } 100% { transform: translate3d(0,0,0) scale(1); } }
@keyframes floaty2  { 0% { transform: translate3d(0,0,0) scale(1); } 50% { transform: translate3d(-30px,22px,0) scale(.94); } 100% { transform: translate3d(0,0,0) scale(1); } }
@keyframes shimmer  { from { background-position: -400px 0; } to { background-position: 400px 0; } }

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

/* ============================================================================
   FORMS
   ========================================================================== */
label { display: block; font-weight: 600; font-size: 0.88rem; margin: 1rem 0 0.4rem; color: var(--text); }

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], textarea, select {
  width: 100%;
  padding: 0.7rem 0.9rem;
  background: var(--surface-2);
  border: 1.5px solid transparent;
  border-radius: var(--radius);
  font-size: 0.94rem;
  font-family: inherit;
  color: var(--text);
  transition: border-color .18s var(--ease-out), box-shadow .18s var(--ease-out), background .18s var(--ease-out);
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover, textarea:hover, select:hover { background: var(--surface-3); }
input:focus, textarea:focus, select:focus {
  outline: none;
  background: var(--bg-2);
  border-color: var(--accent);
  box-shadow: var(--ring);
}
textarea { min-height: 90px; resize: vertical; line-height: 1.55; }
select { appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2397a1bd' d='M1 1.5 6 6.5 11 1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.7rem center; padding-right: 2rem;
}

/* ============================================================================
   BUTTONS
   ========================================================================== */
button {
  margin-top: 1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.62rem 1.15rem;
  font-size: 0.93rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  letter-spacing: -0.01em;
  transition: background .16s var(--ease-out), transform .12s var(--ease-out), opacity .18s;
}
button:hover { background: var(--accent-hover); }
button:active { transform: scale(0.97); }
button:focus-visible { outline: var(--focus, 2px solid var(--accent)); outline-offset: 2px; }
button:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.link-btn {
  background: none; box-shadow: none; color: var(--muted);
  padding: 0.3rem 0.5rem; margin: 0; font-weight: 500;
}
.link-btn:hover { background: none; box-shadow: none; filter: none; color: var(--text); transform: none; }

.small-btn {
  margin: 0; padding: 0.34rem 0.75rem; font-size: 0.8rem; font-weight: 600;
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--border-strong); box-shadow: none;
}
.small-btn:hover { background: var(--surface-2); filter: none; box-shadow: none; }
.small-btn.primary-btn { background: var(--accent); color: #fff; border: none; box-shadow: none; }
.small-btn.primary-btn:hover { background: var(--accent-hover); }

.danger {
  background: rgba(220,38,38,0.06); color: var(--error);
  border: 1px solid rgba(220,38,38,0.30); margin: 0; padding: 0.35rem 0.75rem;
  box-shadow: none; font-weight: 600; font-size: 0.8rem;
}
.danger:hover { background: rgba(220,38,38,0.12); filter: none; box-shadow: none; }

.icon-btn {
  margin: 0; width: 34px; height: 34px; padding: 0; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
  border-radius: 50%; box-shadow: none; font-size: 0.85rem; font-weight: 500;
  transition: transform .18s var(--ease-spring), background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); filter: none; box-shadow: none; transform: rotate(90deg); }

/* ============================================================================
   CARDS / LAYOUT PRIMITIVES
   ========================================================================== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}

.container { max-width: 880px; margin: 2.2rem auto; padding: 0 1.75rem 4rem; animation: fadeUp .32s var(--ease-out); }
.container.wide { max-width: 1120px; }
.section-heading { margin: 0 0 0.3rem; font-size: 1.9rem; font-weight: 700; letter-spacing: -0.03em; }
.page-intro { color: var(--muted); margin: 0; max-width: 60ch; line-height: 1.55; }
.page-kicker {
  display: inline-block; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 0.45rem;
}
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1.25rem; margin-bottom: 2rem; padding-bottom: 1.4rem; border-bottom: 1px solid var(--border); }
.head-cta { margin-top: 0; white-space: nowrap; padding: 0.62rem 1.15rem; border-radius: var(--radius); }
.head-actions { display: flex; gap: 0.5rem; align-items: center; flex-shrink: 0; }
.sub-h { margin: 0 0 0.5rem; font-size: 0.95rem; }
.mt { margin-top: 0.75rem; }

/* ============================================================================
   AUTH — split screen
   ========================================================================== */
.auth { display: flex; min-height: 100vh; background: var(--bg-2); }

.auth-brand {
  position: relative; overflow: hidden; flex: 0 0 46%;
  background:
    radial-gradient(900px 600px at 85% 110%, #1e3a8a 0%, transparent 60%),
    linear-gradient(160deg, #2563eb 0%, #1e40af 100%);
  display: flex; align-items: center; justify-content: center; padding: 3rem;
}
.orb {
  position: absolute; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle at 32% 30%, rgba(255,255,255,0.75), rgba(255,255,255,0.08) 55%, transparent 72%);
  filter: blur(2px);
}
.orb-a { width: 300px; height: 300px; top: -70px; right: -60px; opacity: .5; animation: floaty 11s ease-in-out infinite; }
.orb-b { width: 190px; height: 190px; bottom: 12%; left: -50px; opacity: .38; animation: floaty2 13s ease-in-out infinite; }
.orb-c { width: 90px; height: 90px; top: 32%; left: 22%; opacity: .45; filter: blur(1px); animation: floaty 9s ease-in-out infinite reverse; }

.auth-brand-inner {
  position: relative; z-index: 1; color: #fff; max-width: 420px; text-align: center;
  display: flex; flex-direction: column; align-items: center;
  animation: fadeUp .5s var(--ease-out);
}
.auth-logo { height: 36px; width: auto; filter: brightness(0) invert(1); margin-bottom: 1.6rem; }
.auth-tagline { font-size: 2.4rem; font-weight: 700; letter-spacing: -0.035em; margin: 0 0 0.55rem; line-height: 1.12; }
.auth-sub { font-size: 1.02rem; opacity: 0.85; margin: 0; line-height: 1.55; max-width: 32ch; }

.auth-panel { flex: 1; display: flex; align-items: center; justify-content: center; padding: 3rem 2rem; }
.auth-form { width: 340px; animation: fadeUp .4s var(--ease-out); }
.auth-logo-sm { height: 24px; width: auto; display: none; margin-bottom: 1.6rem; }
.auth-h { font-size: 1.7rem; margin: 0 0 0.25rem; font-weight: 700; letter-spacing: -0.03em; }
.auth-p { margin: 0 0 1.6rem; }
.fld label { margin: 0 0 0.35rem; font-size: 0.84rem; }
.fld { margin-bottom: 1rem; }
.auth-cta { width: 100%; padding: 0.75rem; font-size: 0.99rem; margin-top: 0.4rem; border-radius: var(--radius-sm); }
.auth-alt { display: block; margin: 1.1rem auto 0; }
.auth-form .error, .auth-form .msg { margin: 0.8rem 0 0; text-align: center; }

/* ============================================================================
   TOP NAV SHELL
   ========================================================================== */
.topnav {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255,255,255,0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.topnav-inner {
  max-width: 1240px; margin: 0 auto; padding: 0.65rem 1.5rem;
  display: flex; align-items: center; gap: 1.5rem;
}
.logo { display: inline-flex; align-items: center; }
.logo-img { height: 22px; width: auto; }

.top-tabs {
  display: flex; gap: 0.2rem; background: var(--surface-2);
  padding: 0.25rem; border-radius: 999px; border: 1px solid var(--border);
}
.nav-item {
  display: flex; align-items: center; gap: 0.45rem;
  background: none; box-shadow: none; color: var(--muted); margin: 0;
  padding: 0.42rem 0.95rem; border-radius: 999px; font-size: 0.88rem; font-weight: 600;
  transition: background .18s var(--ease-out), color .18s, transform .16s var(--ease-spring);
}
.nav-item:hover { background: rgba(255,255,255,0.85); color: var(--text); filter: none; box-shadow: none; transform: none; }
.nav-item.active { background: var(--bg-2); color: var(--accent); box-shadow: 0 2px 8px rgba(16,24,40,0.08); }
.nav-ico { width: 15px; height: 15px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; opacity: 0.9; }

.top-right { margin-left: auto; display: flex; align-items: center; gap: 0.8rem; }
.ws-switch { display: flex; align-items: center; gap: 0.55rem; }
.ws-label { margin: 0; font-size: 0.64rem; text-transform: uppercase; letter-spacing: 0.13em; color: var(--faint); font-weight: 700; }
.ws-row { display: flex; gap: 0.35rem; align-items: center; }
.ws-row select { width: auto; min-width: 130px; max-width: 200px; padding: 0.42rem 1.9rem 0.42rem 0.7rem; font-size: 0.87rem; font-weight: 600; border-radius: 999px; }
.ws-new {
  margin: 0; width: 32px; height: 32px; flex-shrink: 0; padding: 0;
  font-size: 1.1rem; line-height: 1; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
}

.user-menu { position: relative; }
.avatar-btn {
  margin: 0; width: 36px; height: 36px; padding: 0; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--border-strong); box-shadow: none;
  display: inline-flex; align-items: center; justify-content: center; color: var(--muted);
}
.avatar-btn:hover { background: var(--surface-3); filter: none; box-shadow: none; transform: none; color: var(--text); }
.avatar-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; }
.user-pop {
  position: absolute; right: 0; top: calc(100% + 10px); min-width: 220px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 0.8rem 1rem; z-index: 45;
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.15rem;
  animation: popIn .18s var(--ease-out);
  transform-origin: top right;
}
.user-pop-who { font-weight: 600; font-size: 0.88rem; padding-bottom: 0.5rem; margin-bottom: 0.35rem; border-bottom: 1px solid var(--border); width: 100%; }
.user-pop .link-btn { padding-left: 0; }

.app-main { min-height: calc(100vh - 60px); }

/* ============================================================================
   EMPTY STATE
   ========================================================================== */
.empty-hero { text-align: center; max-width: 440px; margin: 9vh auto 0; position: relative; }
.empty-orb {
  width: 110px; height: 110px; margin: 0 auto 1.6rem; border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #60a5fa, #2563eb 62%, #1e40af);
  box-shadow: 0 12px 30px rgba(37,99,235,0.20);
  animation: floaty 8s ease-in-out infinite;
}
.empty-hero h2 { font-size: 1.7rem; margin-bottom: 0.4rem; }

/* ============================================================================
   ARTICLES — staggered list rows
   ========================================================================== */
.articles-grid { display: flex; flex-direction: column; gap: 0.65rem; }
.article-card {
  display: flex; align-items: center; gap: 1rem; cursor: pointer;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.3rem;
  animation: fadeUp .34s var(--ease-out) backwards;
  transition: border-color .18s, box-shadow .2s var(--ease-out), transform .2s var(--ease-out);
}
.article-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-lg); }
.article-card:nth-child(1)  { animation-delay: .02s; }
.article-card:nth-child(2)  { animation-delay: .06s; }
.article-card:nth-child(3)  { animation-delay: .10s; }
.article-card:nth-child(4)  { animation-delay: .14s; }
.article-card:nth-child(5)  { animation-delay: .18s; }
.article-card:nth-child(6)  { animation-delay: .22s; }
.article-card:nth-child(7)  { animation-delay: .26s; }
.article-card:nth-child(8)  { animation-delay: .30s; }
.article-card:nth-child(n+9){ animation-delay: .34s; }

/* row internals: title leads, badges trail right, meta under title */
.article-card-main { order: 1; flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 0.15rem; }
.article-card-title { font-weight: 650; font-size: 1.02rem; letter-spacing: -0.01em; line-height: 1.35; }
.article-card-meta { font-size: 0.8rem; color: var(--muted); display: flex; gap: 0.5rem; flex-wrap: wrap; order: 2; flex-shrink: 0; }
.article-card-top { display: flex; align-items: center; gap: 0.55rem; order: 3; flex-shrink: 0; margin: 0; }

.intent-badge { font-size: 0.64rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); background: var(--accent-tint); padding: 0.18rem 0.55rem; border-radius: 999px; white-space: nowrap; }
.status-pill { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.02em; padding: 0.18rem 0.6rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.status-done { color: var(--ok); border-color: rgba(18,128,92,0.35); background: rgba(18,128,92,0.08); }
.status-running, .status-queued { color: var(--accent); border-color: rgba(37,99,235,0.4); background: var(--accent-tint); }
.status-awaiting_review { color: var(--warn); border-color: rgba(183,121,31,0.35); background: rgba(183,121,31,0.08); }
.status-failed { color: var(--error); border-color: rgba(229,72,77,0.35); background: rgba(229,72,77,0.08); }
.status-interrupted { color: var(--muted); }

/* ============================================================================
   ARTIFACTS — icon bars
   ========================================================================== */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 0.75rem; margin-bottom: 1.5rem; }
.tile {
  position: relative; display: flex; flex-direction: column; justify-content: center;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.15rem 1rem 3.3rem; cursor: pointer; min-height: 74px;
  animation: fadeUp .3s var(--ease-out) backwards;
  transition: border-color .18s, box-shadow .2s var(--ease-out), transform .2s var(--ease-out);
}
.tile::before {
  content: ""; position: absolute; left: 1.05rem; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--accent-tint);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.3'%3E%3Cpath d='M4 2.5h5l3 3v8H4z'/%3E%3Cpath d='M9 2.5v3h3'/%3E%3C/svg%3E") center/18px 18px no-repeat, linear-gradient(#fff,#fff);
  mask: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%232563eb' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 2.5h5l3 3v8H4z'/%3E%3Cpath d='M9 2.5v3h3'/%3E%3C/svg%3E");
  background-color: var(--accent-tint);
  background-size: 17px 17px; background-position: center; background-repeat: no-repeat;
}
.tile:hover { border-color: var(--accent); box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.tile:nth-child(1) { animation-delay: .02s; } .tile:nth-child(2) { animation-delay: .05s; }
.tile:nth-child(3) { animation-delay: .08s; } .tile:nth-child(4) { animation-delay: .11s; }
.tile:nth-child(5) { animation-delay: .14s; } .tile:nth-child(6) { animation-delay: .17s; }
.tile:nth-child(7) { animation-delay: .20s; } .tile:nth-child(8) { animation-delay: .23s; }
.tile:nth-child(n+9) { animation-delay: .26s; }
.tile-name { font-weight: 650; font-size: 0.99rem; margin-bottom: 0.15rem; letter-spacing: -0.01em; }
.tile-meta { color: var(--muted); font-size: 0.8rem; }
.tile-del {
  position: absolute; top: 0.5rem; right: 0.5rem; margin: 0; padding: 0.1rem 0.45rem;
  font-size: 0.78rem; opacity: 0; transition: opacity .15s;
}
.tile:hover .tile-del { opacity: 1; }
.tile-add {
  align-items: center; text-align: center; padding: 1rem;
  border-style: dashed; border-color: var(--border-strong); background: transparent;
}
.tile-add::before { display: none; }
.tile-add:hover { background: var(--accent-tint); border-color: var(--accent); }
.tile-add-plus { font-size: 1.5rem; color: var(--accent); line-height: 1; margin-bottom: 0.2rem; }
.sitemap-card { max-width: 640px; }
.sitemap-row { display: flex; align-items: center; justify-content: space-between; padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
.sitemap-row:last-child { border-bottom: none; }
input[type="file"] { color: var(--muted); font-size: 0.85rem; }
input[type="file"]::file-selector-button {
  margin-right: 0.6rem; padding: 0.35rem 0.7rem; border-radius: 7px;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  font-weight: 600; cursor: pointer; font-family: inherit;
}
input[type="file"]::file-selector-button:hover { background: var(--surface-3); }

/* ============================================================================
   OVERLAY + SHEET (composer)
   ========================================================================== */
/* Scrim is solid + instant (no opacity animation on the root, or the child sheet goes
   translucent mid-fade and page content bleeds through). No backdrop-filter — it flakes
   during compositing and is a perf cost; a solid scrim reads cleaner + flatter. The .sheet
   carries the motion, sliding in over an already-solid scrim. */
.overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(13,20,36,0.55);
  display: flex; align-items: center; justify-content: center; padding: 1.25rem;
}
body.scroll-locked { overflow: hidden; }
.sheet {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 640px; max-width: 100%; max-height: 92vh;
  display: flex; flex-direction: column; overflow: hidden;
  animation: sheetIn .24s var(--ease-out);
}
.sheet-head {
  display: flex; align-items: center; gap: 0.6rem; padding: 1.05rem 1.4rem;
  border-bottom: 1px solid var(--border);
}
.sheet-head strong { font-size: 1.08rem; }
.sheet-sub { display: block; margin-top: 1px; }
.composer-body { flex: 1; overflow: auto; padding: 1.2rem 1.4rem 1.6rem; background: var(--bg); }
.composer-body > button { width: 100%; margin-top: 0.9rem; padding: 0.72rem; font-size: 0.98rem; }

.field { display: flex; flex-direction: column; gap: 0.32rem; margin-bottom: 0.95rem; }
.field label { margin: 0; font-size: 0.83rem; color: var(--text); font-weight: 600; }
.field label .opt { font-style: normal; font-weight: 500; color: var(--faint); font-size: 0.76rem; margin-left: 0.3rem; text-transform: uppercase; letter-spacing: 0.05em; }
.field-row { display: flex; gap: 0.8rem; }
.field-row .field { flex: 1; min-width: 0; }

/* grouped form sections */
.form-group {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.05rem 1.15rem 0.75rem; margin-bottom: 0.9rem;
}
.form-group .field:last-child { margin-bottom: 0.35rem; }
.group-kicker {
  display: block; font-size: 0.67rem; font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 0.75rem;
}

/* switch toggles */
.switch-list { display: flex; flex-direction: column; gap: 0.15rem; }
.switch-row {
  display: flex; align-items: center; gap: 0.85rem; font-weight: 400; font-size: 0.9rem;
  margin: 0 0 0.3rem; padding: 0.5rem 0.55rem; border-radius: var(--radius-sm); cursor: pointer;
  transition: background .15s;
}
.switch-row:hover { background: var(--surface-2); }
.switch-txt { display: flex; flex-direction: column; gap: 1px; font-weight: 550; line-height: 1.3; }
.switch-txt small { color: var(--muted); font-weight: 400; font-size: 0.78rem; }

/* composer read-only add-ons reflection */
.addons-readout { padding-bottom: 1.05rem; }
.addons-line { margin: 0; font-weight: 600; font-size: 0.95rem; color: var(--text); }
.addons-hint { margin: 0.35rem 0 0; }
.addons-card .switch-list { margin: 0.4rem 0 0.6rem; max-width: 520px; }
.addons-card #addons-save { margin-top: 0.4rem; }
.switch { position: relative; display: inline-block; width: 36px; height: 21px; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .knob {
  position: absolute; inset: 0; border-radius: 999px; background: var(--surface-3);
  border: 1px solid var(--border-strong); pointer-events: none;
  transition: background .2s var(--ease-out), border-color .2s;
}
.switch .knob::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(16,24,40,0.3);
  transition: transform .2s var(--ease-spring);
}
.switch input:checked + .knob { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .knob::after { transform: translateX(15px); }
.switch input:focus-visible + .knob { box-shadow: var(--ring); }

/* ============================================================================
   TAKEOVER (result + artifact editor)
   ========================================================================== */
.takeover {
  position: fixed; inset: 0; z-index: 70; background: var(--bg);
  display: flex; flex-direction: column;
  animation: takeoverIn .3s var(--ease-out);
}
.takeover-head {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.85rem 1.6rem;
  border-bottom: 1px solid var(--border); background: var(--bg-2);
  position: sticky; top: 0; z-index: 2; flex-wrap: wrap;
}
.takeover-head strong { font-size: 1.05rem; letter-spacing: -0.015em; }
.takeover-scroll { flex: 1; overflow: auto; display: flex; flex-direction: column; }

.editor-hint { margin: 0 0 0.6rem; color: var(--muted); }
.result-review {
  width: min(860px, 100%); margin: 1.4rem auto 0; padding: 1.3rem 1.5rem;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.result-review label { margin: 0.8rem 0 0.3rem; display: flex; align-items: center; gap: 0.6rem; font-size: 0.85rem; }
.result-review > button { width: 100%; }
.mono-area { width: 100%; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.82rem; min-height: 170px; resize: vertical; margin-bottom: 0.3rem; }

.result-meta { width: min(760px, 100%); margin: 1.3rem auto 0; padding: 0 1.5rem; }
.result-body-md {
  width: min(760px, 100%); margin: 0 auto; padding: 0.6rem 1.5rem 4rem;
  line-height: 1.72; font-size: 1rem; color: var(--text);
}
.result-body-md h1 { font-size: 1.55rem; margin: 1.2rem 0 0.6rem; }
.result-body-md h2 { font-size: 1.28rem; margin: 1.3rem 0 0.5rem; }
.result-body-md h3 { font-size: 1.1rem; margin: 1.1rem 0 0.35rem; }
.result-body-md p { margin: 0.7rem 0; }
.result-body-md ul, .result-body-md ol { margin: 0.5rem 0 0.5rem 1.3rem; }
.result-body-md li { margin: 0.3rem 0; }
.result-body-md strong { color: var(--text); }
.result-body-md a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.result-body-md table { border-collapse: collapse; margin: 0.8rem 0; width: 100%; }
.result-body-md td, .result-body-md th { border: 1px solid var(--border); padding: 0.4rem 0.6rem; text-align: left; }
.result-body-md blockquote { border-left: 3px solid var(--accent); margin: 0.8rem 0; padding: 0.2rem 0 0.2rem 1rem; color: var(--muted); }
.result-body-md code { background: var(--surface-2); padding: 0.1rem 0.35rem; border-radius: 5px; font-size: 0.88em; }

.run-progress {
  display: flex; align-items: center; gap: 0.7rem; color: var(--muted);
  padding: 2.2rem 0; animation: fadeIn .3s;
}
.spinner {
  width: 14px; height: 14px; border: 2px solid rgba(37,99,235,0.22); border-top-color: var(--accent);
  border-radius: 50%; display: inline-block; animation: spin 0.7s linear infinite;
}

/* article in-place editor */
.article-editor { animation: fadeIn .25s; }
.article-editor .mono-area { min-height: 55vh; }

/* rich-edit contenteditable (shared by article + review editors) */
.rich-edit {
  overflow: auto; min-height: 300px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.95rem 1.15rem; background: var(--bg-2);
  line-height: 1.65; outline: none;
}
.rich-edit > :first-child { margin-top: 0; }
.rich-edit:focus { border-color: var(--accent); box-shadow: var(--ring); }
.rich-toggle { margin: 0; font-weight: 500; }

/* artifact editor body */
.ae-body {
  flex: 1; display: flex; flex-direction: column;
  width: min(880px, 100%); margin: 0 auto; padding: 1.2rem 1.5rem 2rem; overflow: auto;
}
.ae-body label { margin: 0.6rem 0 0.35rem; font-size: 0.84rem; color: var(--muted); }
.ae-content { flex: 1; min-height: 340px; resize: vertical; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.88rem; }
.ae-preview {
  flex: 1; overflow: auto; min-height: 340px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 1rem 1.2rem; background: var(--bg-2);
  width: auto; margin: 0;
}
.ae-preview > :first-child { margin-top: 0; }
.ae-preview[contenteditable="true"]:focus { border-color: var(--accent); box-shadow: var(--ring); outline: none; }

/* ============================================================================
   MODALS (small dialogs)
   ========================================================================== */
.modal {
  position: fixed; inset: 0; background: rgba(13,20,36,0.55);
  display: flex; align-items: center; justify-content: center; padding: 1rem; z-index: 80;
}
.modal-box {
  width: 440px; max-width: 100%; max-height: 86vh; overflow: auto; margin: 0;
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  animation: popIn .2s var(--ease-out);
}
.modal-box label { display: block; }
.modal-box input { margin-bottom: 0.3rem; }
.modal-head { display: flex; align-items: center; margin-bottom: 0.75rem; }
.modal-head strong { flex: 1; font-size: 1.1rem; }
.modal-actions { display: flex; gap: 0.6rem; justify-content: flex-end; margin-top: 1.1rem; }
.modal-actions button { margin: 0; }
#dialog-message { margin: 0 0 0.6rem; line-height: 1.5; }
#dialog-input { width: 100%; }

/* ============================================================================
   FILE INPUT (styled trigger + filename readout; native input hidden)
   ========================================================================== */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.file-row { display: flex; align-items: center; gap: 0.7rem; margin-top: 0.4rem; flex-wrap: wrap; }
.file-btn {
  display: inline-flex; align-items: center; padding: 0.42rem 0.85rem; margin: 0;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text); font-weight: 600; font-size: 0.85rem; cursor: pointer;
  transition: background .15s var(--ease-out);
}
.file-btn:hover { background: var(--surface-3); }
.file-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============================================================================
   TOAST (replaces native alert; Sonner-style, bottom-right, auto-dismiss)
   ========================================================================== */
.toast-host {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 200;
  display: flex; flex-direction: column; gap: 0.5rem; align-items: flex-end; pointer-events: none;
}
.toast {
  pointer-events: auto; max-width: 360px; padding: 0.7rem 0.95rem; cursor: pointer;
  background: var(--bg-2); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); font-size: 0.9rem; line-height: 1.4;
  opacity: 0; transform: translateY(8px);
  transition: opacity .2s var(--ease-out), transform .2s var(--ease-out);
}
.toast.in { opacity: 1; transform: none; }
.toast-ok { border-left: 3px solid var(--ok); }
.toast-err { border-left: 3px solid var(--error); }

/* ============================================================================
   BOOT SCREEN (covers free-tier cold start; removed once /api/me resolves)
   ========================================================================== */
.boot {
  position: fixed; inset: 0; z-index: 500; background: var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 2rem; text-align: center;
}
.boot.hidden { display: none; }
.boot-inner { display: flex; flex-direction: column; align-items: center; max-width: 30rem; animation: fadeIn .3s var(--ease-out); }
.boot-logo { height: 34px; width: auto; margin-bottom: 1.5rem; }
.boot-title { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
.boot-msg { margin: 0.5rem 0 0; color: var(--muted); font-size: 0.92rem; line-height: 1.55; }
.boot-msg-slow { display: none; }
.boot.boot-slow .boot-msg-normal { display: none; }
.boot.boot-slow .boot-msg-slow { display: block; }
.boot-bar { margin-top: 1.5rem; width: 180px; height: 3px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.boot-bar span { display: block; width: 40%; height: 100%; border-radius: 999px; background: var(--accent); animation: bootSlide 1.3s var(--ease-in-out) infinite; }
@keyframes bootSlide { 0% { transform: translateX(-120%); } 100% { transform: translateX(320%); } }

/* ============================================================================
   COSTS
   ========================================================================== */
.costs-hero {
  padding: 1.1rem 1.4rem; margin-bottom: 1.25rem;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); animation: fadeUp .3s var(--ease-out);
}
.costs-total { font-size: 1.25rem; color: var(--text); }
.cost-card { margin-bottom: 0.9rem; animation: fadeUp .32s var(--ease-out) backwards; }
.cost-card:nth-child(2) { animation-delay: .05s; }
.cost-card:nth-child(3) { animation-delay: .1s; }
.cost-head { display: flex; align-items: baseline; justify-content: space-between; border-bottom: 1px solid var(--border); padding-bottom: 8px; margin-bottom: 10px; }
.cost-head .cost-total { font-weight: 750; color: var(--accent); }
.cost-providers { margin-bottom: 10px; }
.cost-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.cost-table { width: 100%; border-collapse: collapse; }
.cost-table td { padding: 5px 0; border-bottom: 1px solid var(--border); }
.cost-table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--text); }

/* ============================================================================
   SETTINGS
   ========================================================================== */
.settings-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 1.25rem; align-items: start; }
.settings-col { display: flex; flex-direction: column; }
.user-row { display: flex; align-items: center; gap: 0.6rem; padding: 0.7rem 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.user-row:last-child { border-bottom: none; }
.user-email { font-weight: 650; }
.user-meta { color: var(--muted); font-size: 0.85rem; }
.add-user { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.add-user input { flex: 1; min-width: 150px; }
.add-user select { width: auto; min-width: 120px; }
.add-user button { margin: 0; }
.model-line { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.55rem 0; border-bottom: 1px solid var(--border); }
.model-line:last-child { border-bottom: none; }
.model-tier { color: var(--text); font-weight: 600; font-size: 0.9rem; }
.model-line code { background: var(--surface-2); padding: 0.2rem 0.5rem; border-radius: 6px; font-size: 0.84rem; color: var(--accent); }

/* ============================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 1020px) {
  .settings-grid { grid-template-columns: 1fr; }
  .cost-cols { grid-template-columns: 1fr; }
  .ws-label { display: none; }
}

@media (max-width: 860px) {
  .auth-brand { display: none; }
  .auth-logo-sm { display: block; }
  .topnav-inner { flex-wrap: wrap; gap: 0.6rem; padding: 0.6rem 1rem; }
  .top-tabs { order: 3; width: 100%; justify-content: space-between; overflow-x: auto; }
  .th-ghost { display: none; }  /* drop the alignment spacer on mobile; tabs go full-width */
  .track-head { padding: 0 1rem; }
  .nav-item { padding: 0.42rem 0.7rem; font-size: 0.82rem; flex: 1; justify-content: center; }
  .top-right { margin-left: auto; }
  .container { margin: 1.4rem auto; padding: 0 1.1rem 3rem; }
  .page-head { flex-direction: column; align-items: stretch; gap: 0.9rem; }
  .head-cta { width: 100%; }
  .section-heading { font-size: 1.55rem; }
  .article-card { flex-wrap: wrap; row-gap: 0.4rem; }
  .article-card-main { flex-basis: 100%; }
  .article-card-meta { order: 3; }
  .article-card-top { order: 2; }
  .takeover-head { padding: 0.7rem 0.9rem; gap: 0.4rem; }
  .takeover-head .small-btn { font-size: 0.72rem; padding: 0.3rem 0.55rem; }
  .field-row { flex-direction: column; gap: 0; }
  .ws-row select { min-width: 100px; max-width: 140px; }
}

@media (max-width: 480px) {
  .nav-item .nav-ico { display: none; }
  .overlay { padding: 0; align-items: flex-end; }
  .sheet { border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 94vh; }
}


/* ============================================================================
   MULTI-TRACK NAV: track tabs (header) + section sub-nav + account-menu extras
   ============================================================================ */
.track-tab.soon { opacity: 0.45; cursor: not-allowed; }
.track-tab.soon:hover { background: none; color: var(--muted); }

.section-subnav {
  display: flex; gap: 1.1rem; align-items: center;
  max-width: 1240px; margin: 1.5rem auto 0; padding: 0 1.5rem 0;
}
.subnav-item {
  background: none; box-shadow: none; color: var(--muted); margin: 0;
  padding: 0.35rem 0.1rem 0.55rem; border-radius: 0; font-size: 0.98rem; font-weight: 600;
  border-bottom: 2px solid transparent; transition: color .16s, border-color .16s;
}
.subnav-item:hover { background: none; color: var(--text); box-shadow: none; filter: none; transform: none; }
.subnav-item.active { color: var(--accent); border-bottom-color: var(--accent); }

.user-pop-sep { height: 1px; background: var(--border); width: 100%; margin: 0.4rem 0; }
.addons-scope { margin: 0 0 0.7rem; }


/* per-run byline on cards + viewable person voice artifacts */
.article-card-byline { color: var(--faint); font-size: 0.82rem; font-weight: 600; margin: 0; }
.person-row { border-top: 1px solid var(--border); }
.person-row:first-child { border-top: none; }
.person-name { width: 100%; display: flex; align-items: center; gap: 0.55rem; text-align: left; background: none; box-shadow: none; color: var(--text); font-weight: 600; padding: 0.6rem 0.45rem; border-radius: 9px; cursor: pointer; }
.person-name:hover { background: var(--surface-2); color: var(--text); box-shadow: none; filter: none; transform: none; }
.person-caret { color: var(--accent); flex-shrink: 0; transition: transform .16s var(--ease-out); }
.person-name.open .person-caret { transform: rotate(90deg); }
.person-nm { flex: 1; }
.person-hint { font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--faint); font-weight: 700; }
.person-arts { margin: 0.1rem 0 0.6rem; padding-left: 0.45rem; display: flex; flex-direction: column; gap: 0.55rem; }
.person-art { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 0.6rem 0.8rem; }
.person-art-top { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.35rem; }
.person-art-h { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--faint); font-weight: 700; }
.person-art-edit { padding: 0.2rem 0.6rem; font-size: 0.72rem; }
.person-art-body { font-size: 0.87rem; color: var(--text); line-height: 1.55; max-height: 260px; overflow-y: auto; }
.person-art-body > :first-child { margin-top: 0; }
.person-art-body h1, .person-art-body h2, .person-art-body h3 { font-size: 0.95rem; margin: 0.6rem 0 0.25rem; }
.person-art-body p, .person-art-body ul, .person-art-body ol { margin: 0.3rem 0; }


/* voice-artifact editor: apply-to-other-track checkbox */
.ae-apply-both-row { display: flex; align-items: center; gap: 0.5rem; margin: 0.1rem 0 0.6rem; font-size: 0.85rem; color: var(--muted); font-weight: 500; cursor: pointer; }
.ae-apply-both-row input { width: auto; margin: 0; }


/* Configs: workspace-level settings card, subtly set apart from the per-track cards */
.workspace-card { border-style: dashed; background: var(--surface); }
.workspace-card .field { margin-top: 0.5rem; }


/* heading-case selector in the add-ons card */
.heading-case-row { margin-top: 0.7rem; }
.heading-case-row select { max-width: 260px; }
.heading-case-hint { margin-top: 0.35rem; }

/* ============================================================================
   PIPELINE — step-by-step run visibility (live while running + kept when done)
   ========================================================================== */
.pipeline { width: min(760px, 100%); margin: 1.2rem auto 0; padding: 0 1.5rem; animation: fadeIn .3s; }
.pipeline-head {
  display: flex; align-items: center; gap: 0.5rem; width: 100%;
  background: none; border: none; cursor: pointer; padding: 0.4rem 0; color: var(--text);
  font: inherit; text-align: left;
}
.pipeline-caret { color: var(--faint); font-size: 0.78rem; transition: transform .2s var(--ease-out); }
.pipeline.collapsed .pipeline-caret { transform: rotate(-90deg); }
.pipeline.collapsed .pipeline-list { display: none; }
.pipeline-title { font-weight: 700; font-size: 0.92rem; letter-spacing: -0.01em; }
.pipeline-count { color: var(--faint); font-size: 0.8rem; font-weight: 500; }

.pipeline-list { list-style: none; margin: 0.5rem 0 0; padding: 0; position: relative; }
.pipeline-list::before {
  content: ""; position: absolute; left: 6px; top: 8px; bottom: 14px; width: 2px;
  background: var(--border-strong); border-radius: 2px;
}
.step-row { position: relative; }
.step-head {
  display: flex; align-items: flex-start; gap: 0.75rem; width: 100%;
  background: none; border: none; text-align: left; cursor: pointer; font: inherit; color: var(--text);
  padding: 0.5rem 0.4rem; border-radius: var(--radius-sm); transition: background .15s;
}
.step-head:hover { background: var(--surface-2); }
.step-head.is-active, .step-head.is-active:hover { cursor: default; background: none; }

.step-dot {
  flex: none; width: 14px; height: 14px; border-radius: 50%; margin-top: 2px; position: relative; z-index: 1;
  background: var(--bg-2); border: 2px solid var(--border-strong);
}
.step-dot.done { background: var(--accent); border-color: var(--accent); }
.step-dot.done::after {
  content: ""; position: absolute; left: 3px; top: 0; width: 3px; height: 7px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.step-dot.active { border-color: var(--accent); animation: dotPulse 1.1s var(--ease-out) infinite; }

.step-main { flex: 1; display: flex; flex-direction: column; gap: 0.12rem; min-width: 0; }
.step-label { font-weight: 600; font-size: 0.9rem; letter-spacing: -0.005em; }
.step-blurb { color: var(--muted); font-size: 0.8rem; line-height: 1.35; }
.step-time { color: var(--faint); font-size: 0.75rem; margin-top: 2px; white-space: nowrap; }
.step-caret { color: var(--faint); font-size: 1.05rem; line-height: 1; margin-top: 1px; transition: transform .2s var(--ease-out); }
.step-row.open .step-caret { transform: rotate(90deg); }

.step-output {
  margin: 0 0 0.5rem 1.55rem; padding: 0.85rem 1.1rem; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm); animation: fadeIn .2s;
  max-height: 460px; overflow: auto; font-size: 0.9rem; line-height: 1.6; color: var(--text);
}
.step-output > :first-child { margin-top: 0; }
.step-output > :last-child { margin-bottom: 0; }
.step-output h1, .step-output h2, .step-output h3, .step-output h4 { font-size: 0.98rem; font-weight: 700; margin: 0.8rem 0 0.35rem; }
.step-output p { margin: 0.5rem 0; }
.step-output ul, .step-output ol { margin: 0.4rem 0 0.4rem 1.2rem; }
.step-output li { margin: 0.25rem 0; }
.step-output code { background: var(--surface-3); padding: 0.1rem 0.35rem; border-radius: 5px; font-size: 0.85em; }
.step-output blockquote { border-left: 3px solid var(--accent); margin: 0.6rem 0; padding: 0.1rem 0 0.1rem 0.9rem; color: var(--muted); }
.step-output table { border-collapse: collapse; width: 100%; margin: 0.5rem 0; }
.step-output td, .step-output th { border: 1px solid var(--border); padding: 0.3rem 0.5rem; font-size: 0.82rem; text-align: left; }
.step-json { white-space: pre-wrap; word-break: break-word; margin: 0; font-size: 0.82rem; }
.step-loading { display: flex; align-items: center; gap: 0.5rem; color: var(--muted); font-size: 0.85rem; }

/* per-step duration chip + output toolbar (copy) */
.step-dur {
  flex: none; align-self: center; color: var(--muted); font-size: 0.72rem; font-weight: 600;
  background: var(--surface-3); border-radius: 999px; padding: 0.08rem 0.45rem; white-space: nowrap;
}
.step-out-bar { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin: 0 0 0.55rem; }
.step-out-kind { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--faint); }
.step-copy {
  font-size: 0.72rem; padding: 0.2rem 0.6rem; border: 1px solid var(--border); border-radius: 999px;
  background: var(--bg-2); color: var(--muted); cursor: pointer; transition: background .15s, color .15s;
}
.step-copy:hover { background: var(--surface-3); color: var(--text); }

@keyframes dotPulse {
  0%   { box-shadow: 0 0 0 0 rgba(37,99,235,0.35); }
  70%  { box-shadow: 0 0 0 6px rgba(37,99,235,0); }
  100% { box-shadow: 0 0 0 0 rgba(37,99,235,0); }
}

/* ============================================================================
   STATES + A11Y (P1) — visible keyboard focus, press feedback, touch hover-gating
   ========================================================================== */
/* One instant focus ring for every interactive control (never fades in). */
a:focus-visible, .small-btn:focus-visible, .icon-btn:focus-visible, .file-btn:focus-visible,
.link-btn:focus-visible, .nav-item:focus-visible, .track-tab:focus-visible, .subnav-item:focus-visible,
.article-card:focus-visible, .tile:focus-visible, .tile-add:focus-visible, .step-head:focus-visible,
.person-name:focus-visible, .pipeline-head:focus-visible, .cost-card:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-sm);
}
/* Press feedback on smaller pressables (buttons already handled). */
.small-btn:active, .icon-btn:active, .file-btn:active, .track-tab:active, .nav-item:active { transform: scale(0.97); }
/* Consistent disabled treatment across control types. */
.small-btn:disabled, .small-btn[disabled], button[disabled] { opacity: 0.55; cursor: not-allowed; transform: none; }
/* Touch devices fire :hover on tap and it sticks — drop the transform-lifts there. */
@media (hover: none) {
  .tile:hover, .article-card:hover { transform: none; }
}

/* In-button spinner: add class 'is-loading' + set disabled while an async action runs. */
button.is-loading, .small-btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
button.is-loading::after, .small-btn.is-loading::after {
  content: ""; position: absolute; top: 50%; left: 50%; width: 15px; height: 15px; margin: -7.5px 0 0 -7.5px;
  border: 2px solid rgba(255,255,255,0.5); border-top-color: #fff; border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.small-btn.is-loading:not(.primary-btn)::after { border-color: rgba(37,99,235,0.35); border-top-color: var(--accent); }

/* ============================================================================
   SKELETONS (loading placeholders that match final layout)
   ========================================================================== */
.skeleton {
  background: linear-gradient(100deg, var(--surface-2) 30%, var(--surface-3) 50%, var(--surface-2) 70%);
  background-size: 400px 100%; border-radius: var(--radius-sm); animation: shimmer 1.3s linear infinite;
}
.sk-card { height: 84px; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 0.7rem;
  background: var(--card); padding: 1.1rem 1.3rem; display: flex; flex-direction: column; gap: 0.6rem; }
.sk-line { height: 12px; border-radius: 999px; }
.sk-line.w-60 { width: 60%; } .sk-line.w-40 { width: 40%; } .sk-line.w-30 { width: 30%; }

/* ============================================================================
   IDEA GRID (L1 — LinkedIn idea-first)
   ========================================================================== */
.idea-grid { width: min(820px, 100%); margin: 0 auto; padding: 0.6rem 1.5rem 4rem; display: flex; flex-direction: column; gap: 0.7rem; }
.idea-card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); padding: 1rem 1.1rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 0.2rem; animation: fadeIn .2s var(--ease-out); }
.idea-desc { font-weight: 650; font-size: 1rem; line-height: 1.4; letter-spacing: -0.01em; }
.idea-tags { display: flex; flex-direction: column; gap: 0.3rem; margin-top: 0.55rem; }
.idea-tag { font-size: 0.85rem; color: var(--muted); line-height: 1.45; }
.idea-tag b { color: var(--text); font-weight: 700; margin-right: 0.4rem; text-transform: uppercase; font-size: 0.68rem; letter-spacing: 0.05em; }
.idea-actions { display: flex; gap: 0.6rem; align-items: center; border-top: 1px solid var(--border); padding-top: 0.8rem; margin-top: 0.7rem; }
.idea-steer { flex: 1; min-width: 0; }
.idea-create { flex: none; white-space: nowrap; }
.idea-set-card { border-style: dashed; }
.idea-set-badge { font-size: 0.64rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); background: var(--accent-tint); padding: 0.18rem 0.55rem; border-radius: 999px; }

/* ============================================================================
   PLATFORM SECTIONS (Production / Content Hub / Performance)
   ========================================================================== */
/* the top section-nav reuses .top-tabs + .nav-item (incl. .active) — no extra rules needed */

/* Production home: content-type tiles */
.prod-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0.9rem; margin-top: 1.4rem; }
.prod-tile {
  display: flex; flex-direction: column; gap: 0.4rem; align-items: flex-start; text-align: left;
  margin: 0; padding: 1.2rem 1.25rem; background: var(--card); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); cursor: pointer;
  transition: border-color .15s var(--ease-out), box-shadow .15s var(--ease-out), transform .12s var(--ease-out);
}
.prod-tile:hover { background: var(--card); border-color: var(--accent); box-shadow: var(--shadow-lg); }
.prod-tile:active { transform: scale(0.99); }
.prod-tile-name { font-weight: 700; font-size: 1.05rem; letter-spacing: -0.01em; }
.prod-tile-desc { font-weight: 400; font-size: 0.86rem; color: var(--muted); line-height: 1.45; }
.prod-tile.soon { opacity: 0.5; cursor: not-allowed; }
.prod-tile.soon:hover { background: var(--card); border-color: var(--border); box-shadow: var(--shadow); }

/* Track workspace head: breadcrumb back + content-type switcher */
/* Track head: same centered container + logo-width spacer as the topnav, so the track
   tabs line up directly under the section-nav (Production | Content Hub | Performance). */
.track-head { max-width: 1240px; margin: 0 auto 0.5rem; padding: 0 1.5rem; display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
.th-ghost { visibility: hidden; flex: none; }
.back-btn { margin: 0; padding: 0.3rem 0.45rem; white-space: nowrap; }
.track-head .track-tabs { display: flex; gap: 0.3rem; flex-wrap: wrap; }

/* Content Hub: per-card track badge */
.hub-track-badge { font-size: 0.64rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); background: var(--accent-tint); padding: 0.18rem 0.55rem; border-radius: 999px; white-space: nowrap; }

/* coming-soon / empty-state placeholder panel */
.soon-panel { max-width: 520px; margin: 8vh auto 0; text-align: center; padding: 2.5rem 2rem; border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); background: var(--card); animation: fadeIn .25s var(--ease-out); }
.soon-panel h2 { font-size: 1.5rem; margin: 0 0 0.5rem; }
.soon-panel p { margin: 0 auto; max-width: 44ch; line-height: 1.55; }
.soon-badge { display: inline-block; font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); padding: 0.2rem 0.6rem; border-radius: 999px; margin-bottom: 1rem; }

/* ============================================================================
   WYSIWYG rich-edit toolbar (article/post output + artifacts)
   ========================================================================== */
.rich-toolbar { display: flex; flex-wrap: wrap; gap: 0.25rem; margin: 0 0 0.55rem; }
.rt-btn {
  margin: 0; padding: 0.32rem 0.6rem; font-size: 0.82rem; font-weight: 600; line-height: 1;
  background: var(--bg-2); color: var(--muted); border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer; transition: background .12s var(--ease-out), color .12s var(--ease-out);
}
.rt-btn:hover { background: var(--surface-2); color: var(--text); }
.rt-btn:active { transform: scale(0.96); }
.rt-b { font-weight: 800; }
.rt-i { font-style: italic; }

/* ============================================================================
   L1 refinements: editable ideas, nested posts, card delete
   ========================================================================== */
/* inline-editable idea fields */
.idea-field { outline: none; border-radius: var(--radius-sm); transition: background .12s var(--ease-out), box-shadow .12s var(--ease-out); }
.idea-field:hover { background: var(--surface-2); }
.idea-field:focus { background: var(--bg-2); box-shadow: var(--ring); }
.idea-desc.idea-field { padding: 0.25rem 0.4rem; margin: -0.25rem -0.4rem 0; }
.idea-tag { display: block; }
.idea-tag-val { display: inline; padding: 0.05rem 0.3rem; }
.idea-editbar { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.65rem; }
.idea-dirty { color: var(--warn); font-weight: 600; }

/* posts nested under their idea set */
.idea-nest { margin: -0.2rem 0 0.7rem 1.4rem; padding-left: 0.95rem; border-left: 2px solid var(--border); display: flex; flex-direction: column; gap: 0.55rem; }
.idea-nest .article-card { background: var(--bg-2); }
.nest-badge { font-size: 0.62rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); padding: 0.14rem 0.5rem; border-radius: 999px; }

/* card delete (admin) — reveals on hover */
.card-del { margin: 0; padding: 0; width: 26px; height: 26px; flex: none; display: inline-flex; align-items: center; justify-content: center; background: none; color: var(--faint); border: none; border-radius: var(--radius-sm); opacity: 0; cursor: pointer; transition: opacity .12s var(--ease-out), background .12s, color .12s; }
.article-card:hover .card-del, .card-del:focus-visible { opacity: 1; }
.card-del:hover { background: rgba(220,38,38,0.10); color: var(--error); }

/* Performance: per-client dashboards (Internal / External) */
.perf-body { margin-top: 0.75rem; }
.perf-frame { width: 100%; height: calc(100vh - 220px); min-height: 460px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
.perf-fallback { display: flex; flex-direction: column; align-items: flex-start; gap: 0.65rem; max-width: 560px; padding: 1.6rem 1.75rem; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--card); }
.perf-fallback-title { font-weight: 700; font-size: 1.05rem; }
.perf-fallback p { margin: 0; line-height: 1.55; }
.perf-fallback .primary-btn { text-decoration: none; margin-top: 0.2rem; }

/* ============================================================================
   Week grouping + progressive "Show more" + previously-created chips
   ========================================================================== */
/* week header (SEO / Thought Leadership / Content Hub nest by week, Monday start) */
.week-group-head { display: flex; align-items: baseline; gap: 0.6rem; margin: 1.15rem 0 0.5rem; }
.week-group-head:first-child { margin-top: 0.2rem; }
.week-badge { font-weight: 700; font-size: 0.9rem; color: var(--text); }
.week-count { font-size: 0.68rem; font-weight: 700; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 0.08rem 0.5rem; }
/* week nest shares the idea-nest indent + connector */
.week-nest { margin: -0.1rem 0 0.7rem 1.4rem; padding-left: 0.95rem; border-left: 2px solid var(--border); display: flex; flex-direction: column; gap: 0.55rem; }

/* progressive disclosure */
.show-more-btn { align-self: flex-start; margin-top: 0.15rem; background: none; border: none; color: var(--accent); font-weight: 600; font-size: 0.82rem; cursor: pointer; padding: 0.25rem 0.15rem; border-radius: var(--radius-sm); }
.show-more-btn:hover { text-decoration: underline; }

/* "Previously created" record under each idea card */
.idea-created { margin-top: 0.6rem; padding-top: 0.55rem; border-top: 1px dashed var(--border); }
.idea-created-label { font-size: 0.62rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 0.4rem; }
.idea-created-row { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.idea-created-item { display: inline-flex; align-items: center; gap: 0.4rem; max-width: 100%; font-size: 0.78rem; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 0.22rem 0.65rem; cursor: pointer; transition: border-color .12s var(--ease-out), color .12s; }
.idea-created-item:hover { border-color: var(--accent); color: var(--accent); }
.idea-created-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 22ch; }
.idea-created-item .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); flex: none; }
.idea-created-item .dot.status-done { background: var(--ok); }
.idea-created-item .dot.status-running, .idea-created-item .dot.status-queued { background: var(--accent); }
.idea-created-item .dot.status-failed, .idea-created-item .dot.status-interrupted { background: var(--error); }

/* person LinkedIn profile URL (Configs → People) */
.person-url .person-url-row { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.3rem; }
.person-url .person-url-input { flex: 1; min-width: 0; }
.person-url .person-url-save { flex: none; }

/* ---- step versioning (TL): editable steps, version bar, diff ---- */
.step-editrun, .step-regen { margin-left: 6px; }
.step-edit-area { width: 100%; min-height: 38vh; box-sizing: border-box; resize: vertical; }
.step-edit-bar { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }

.version-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 12px; margin: 0 0 14px; border: 1px solid var(--border, #e5e7eb);
  border-radius: var(--radius, 8px); background: var(--surface-2, #f8fafc); }
.version-bar.pinned { border-color: var(--accent, #2563eb); box-shadow: 0 0 0 1px var(--accent, #2563eb) inset; }
.ver-badge { font-weight: 600; font-size: .9rem; }
.ver-switch-l { font-size: .85rem; color: var(--muted, #6b7280); display: inline-flex; align-items: center; gap: 6px; }
.ver-switch { padding: 3px 6px; border-radius: 6px; }
.version-bar .spacer { flex: 1; }

.ver-diff { border: 1px solid var(--border, #e5e7eb); border-radius: var(--radius, 8px); padding: 10px 12px; margin: 0 0 14px; }
.ver-diff-label { margin-bottom: 8px; }
.ver-diff-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ver-diff-h { font-weight: 600; font-size: .82rem; margin-bottom: 6px; }
.ver-diff-line { font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; padding: 2px 6px;
  border-radius: 4px; margin-bottom: 2px; white-space: pre-wrap; word-break: break-word; }
.ver-diff-line.add { background: rgba(22, 163, 74, .12); }
.ver-diff-line.rem { background: rgba(220, 38, 38, .12); text-decoration: line-through; opacity: .8; }
@media (max-width: 640px) { .ver-diff-cols { grid-template-columns: 1fr; } }

/* non-destructive "new version — please refresh" banner */
.update-banner { position: fixed; left: 50%; transform: translateX(-50%); bottom: 1.25rem; z-index: 9999; display: flex; align-items: center; gap: 0.75rem; background: var(--text); color: var(--bg-2); padding: 0.55rem 0.6rem 0.55rem 1.1rem; border-radius: 999px; box-shadow: 0 10px 34px rgba(16,24,40,0.22); font-size: 0.88rem; font-weight: 550; animation: fadeIn .2s var(--ease-out); }
.update-banner .update-refresh { background: var(--accent); color: #fff; border: none; border-radius: 999px; padding: 0.38rem 0.95rem; font-weight: 650; cursor: pointer; }
.update-banner .update-refresh:hover { filter: brightness(1.06); }
.update-banner .update-dismiss { background: none; border: none; color: var(--bg-2); opacity: 0.65; cursor: pointer; display: inline-flex; align-items: center; padding: 0.25rem; }
.update-banner .update-dismiss:hover { opacity: 1; }
