/* Aireframes — authenticated app chrome. */

.af-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}
.af-shell.af-shell-minimal {
  grid-template-columns: 1fr;
}
@media (max-width: 900px) {
  .af-shell { grid-template-columns: 1fr; }
  .af-rail { display: none; }
  .af-rail[data-open="1"] { display: flex; position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 50; box-shadow: var(--shadow-pop); }
}

.af-rail {
  background: linear-gradient(180deg, var(--surface-1) 0%, #FDFCFA 100%);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  height: 100vh; position: sticky; top: 0;
}
.af-rail-header {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
/* Wordmark: "AIreframes" — "AI" in the brand accent (green) with
   "reframes" in a muted grey so the initialism reads as the emphasis. */
.af-brand {
  font-family: var(--font-display);
  font-size: 22px; letter-spacing: -0.015em;
  color: var(--text-3);
  transition: transform var(--dur-3) var(--ease-spring);
  display: inline-block;
  line-height: 0;
}
.af-brand:hover { transform: translateY(-1px); color: var(--text-3); }
.af-brand span { color: var(--accent); }
.af-brand img { height: 26px; width: auto; display: block; }

.af-workspace-switcher {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-1);
  font-size: 13px;
  width: 100%;
  text-align: left;
  transition: border-color var(--dur-2) var(--ease), background var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease), transform var(--dur-1) var(--ease);
}
.af-workspace-switcher:hover { background: var(--surface-hover); border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.af-workspace-switcher:focus-visible { outline: 0; box-shadow: var(--ring); border-color: var(--accent); }
.af-workspace-switcher:active { transform: scale(0.98); }
.af-workspace-switcher .meta { color: var(--text-3); font-size: 11px; }
.af-workspace-switcher .af-switcher-caret {
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-3);
  transition: transform var(--dur-2) var(--ease), color var(--dur-2) var(--ease);
}
.af-workspace-switcher:hover .af-switcher-caret { color: var(--text-2); transform: translateY(1px); }

.af-rail-section {
  padding: 12px 8px;
  flex: 1 1 auto;
  overflow: auto;
}
.af-rail-label {
  font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;
  font-weight: 500;
  color: var(--text-3); padding: 8px 10px 6px;
  display: flex; align-items: center; justify-content: space-between;
}
.af-rail-add {
  display: inline-grid; place-items: center;
  width: 22px; height: 22px;
  padding: 0 !important;
  color: var(--text-3);
  border-radius: var(--radius-sm);
}
.af-rail-add:hover { color: var(--accent); background: var(--accent-softer); }

.af-nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; margin: 1px 0;
  border-radius: var(--radius);
  font-size: 13px; color: var(--text-2);
  cursor: pointer;
  position: relative;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
}
.af-nav-item::before {
  content: '';
  position: absolute; left: -8px; top: 50%;
  transform: translateY(-50%) scaleY(0);
  width: 3px; height: 16px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
  transition: transform var(--dur-2) var(--ease-out);
}
.af-nav-item:hover { background: var(--surface-hover); color: var(--text-1); }
.af-nav-item[data-active="1"] { background: var(--surface-2); color: var(--text-1); font-weight: 500; }
.af-nav-item[data-active="1"]::before { transform: translateY(-50%) scaleY(1); }
.af-nav-item:active { transform: scale(0.98); }
.af-nav-item .kbd { margin-left: auto; font-family: var(--font-mono); font-size: 10px; color: var(--text-3); }

.af-rail-footer {
  border-top: 1px solid var(--border);
  padding: 10px;
  display: flex; align-items: center; gap: 8px;
}
.af-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-weak); color: var(--accent);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600;
  letter-spacing: -0.01em;
  flex-shrink: 0;
  transition: transform var(--dur-2) var(--ease-spring);
}
.af-avatar:hover { transform: scale(1.04); }
.af-menu-btn {
  margin-left: auto;
  background: transparent; border: 0; color: var(--text-3);
  padding: 6px; border-radius: var(--radius);
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.af-menu-btn:hover { background: var(--surface-2); color: var(--text-1); }
.af-menu-btn:focus-visible { outline: 0; box-shadow: var(--ring); }

.af-main {
  display: flex; flex-direction: column;
  min-height: 100vh;
  background: var(--surface-0);
}
.af-topbar {
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  background: rgba(250, 250, 249, 0.85);
  backdrop-filter: saturate(160%) blur(8px);
  -webkit-backdrop-filter: saturate(160%) blur(8px);
  position: sticky; top: 0; z-index: 10;
}
.af-topbar h1 { font-size: 16px; font-weight: 500; margin: 0; letter-spacing: -0.01em; }
.af-topbar .breadcrumb { color: var(--text-3); font-size: 13px; }
.af-topbar .spacer { flex: 1; min-width: 0; }

.af-topbar-project .proj-title-wrap {
  display: flex; align-items: center; gap: 10px;
  min-width: 0; flex-shrink: 1;
}
.af-topbar-project .proj-title-wrap h1 {
  font-size: 16px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.af-topbar-project .proj-meta {
  display: flex; gap: 8px; align-items: center; flex-shrink: 1; min-width: 0;
}
.af-topbar-project .proj-meta .proj-sub {
  font-size: 12px; color: var(--text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.af-topbar-project .proj-actions {
  display: flex; gap: 8px; align-items: center; flex-shrink: 0;
}

.chip.small {
  font-size: 10px; padding: 2px 6px;
  letter-spacing: 0.04em;
}

.af-content {
  flex: 1;
  padding: 20px 32px 32px;
  max-width: 1280px; margin: 0 auto; width: 100%;
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px; font-weight: 500; color: var(--text-1);
  white-space: nowrap;
  box-shadow: var(--shadow-xs);
  transition:
    background var(--dur-1) var(--ease),
    border-color var(--dur-1) var(--ease),
    color var(--dur-1) var(--ease),
    box-shadow var(--dur-2) var(--ease),
    transform var(--dur-1) var(--ease);
  user-select: none;
}
.btn:hover { background: var(--surface-hover); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.btn:focus-visible { outline: 0; box-shadow: var(--ring); border-color: var(--accent); }
.btn:active { transform: scale(0.96); box-shadow: var(--shadow-xs); }
.btn.primary {
  background: var(--accent); color: var(--accent-text); border-color: var(--accent);
  box-shadow: var(--shadow-xs), inset 0 1px 0 rgba(255,255,255,0.1);
}
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,0.1); }
.btn.primary:active { background: var(--accent-active); border-color: var(--accent-active); box-shadow: var(--shadow-xs), inset 0 1px 1px rgba(0,0,0,0.08); transform: scale(0.96); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); box-shadow: none; }
.btn.ghost:hover { background: var(--surface-2); color: var(--text-1); box-shadow: none; }
.btn.ghost:active { background: var(--surface-3); box-shadow: none; }
.btn.danger { color: var(--danger); border-color: var(--border); }
.btn.danger:hover { background: var(--danger-weak); border-color: var(--danger); box-shadow: var(--shadow-xs); }
.btn.danger:focus-visible { box-shadow: var(--ring-danger); border-color: var(--danger); }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn.block { width: 100%; justify-content: center; }
/* Radio-style button group used in the publish modal to pick between
   keep / change / remove password. Reuses .btn.block for sizing and
   adds a selected state via the generic data-active pattern. */
.btn.radio { justify-content: flex-start; }
.btn.radio[data-active="1"] { border-color: var(--accent); background: var(--surface-2); color: var(--text-1); font-weight: 500; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; transform: none !important; box-shadow: none !important; }
.btn svg {
  transition: transform var(--dur-2) var(--ease-out-back);
  flex-shrink: 0;
}
.btn:hover svg { transform: translateY(-0.5px); }

/* Dev shortcut button — a discreet pill with a "DEV" tag. */
.af-dev-shortcut {
  width: 100%;
  justify-content: flex-start;
  background: var(--surface-2);
  border-color: transparent;
  box-shadow: none;
}
.af-dev-shortcut:hover { background: var(--accent-softer); border-color: transparent; box-shadow: none; color: var(--accent); }
.af-dev-shortcut .chip { flex-shrink: 0; }

.af-topbar-menu-btn {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px;
  padding: 0 !important;
  color: var(--text-2);
  box-shadow: none;
}
.af-topbar-menu-btn:hover { color: var(--text-1); background: var(--surface-2); border-color: transparent; box-shadow: none; }

/* Input */
.input, .textarea, .select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-1);
  color: var(--text-1);
  font-size: 14px;
  box-shadow: inset 0 1px 1px rgba(23, 22, 20, 0.02);
  transition:
    border-color var(--dur-1) var(--ease),
    box-shadow var(--dur-2) var(--ease),
    background var(--dur-1) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:hover, .textarea:hover, .select:hover { border-color: var(--border-strong); }
.input:focus, .textarea:focus, .select:focus {
  outline: 0;
  border-color: var(--accent);
  box-shadow: var(--ring);
  background: var(--surface-1);
}
.input[disabled], .textarea[disabled], .select[disabled] { background: var(--surface-2); color: var(--text-3); cursor: not-allowed; }
.textarea { min-height: 80px; resize: vertical; font-family: inherit; line-height: 1.5; }
.label {
  display: block;
  font-size: 13px; font-weight: 500;
  color: var(--text-2);
  margin-bottom: 6px;
}
.field { margin-bottom: 16px; }
.hint { font-size: 12px; color: var(--text-3); margin-top: 6px; line-height: 1.45; }

/* Card */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease);
}
.card h2 { font-size: 16px; font-weight: 500; margin: 0 0 12px; letter-spacing: -0.005em; }

/* Badges / chips */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 500; letter-spacing: 0.02em;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border);
  line-height: 1.5;
}
.chip::before {
  content: ''; display: none;
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
  opacity: 0.7;
}
.chip.accent { background: var(--accent-weak); color: var(--accent); border-color: transparent; }
.chip.accent::before { display: inline-block; background: var(--accent); opacity: 1; }
.chip.warn   { background: var(--warn-weak); color: var(--warn-text); border-color: transparent; }
.chip.warn::before { display: inline-block; background: var(--warn); opacity: 1; animation: chipPulse 1.6s ease-in-out infinite; }
.chip.mono   { font-family: var(--font-mono); }
@keyframes chipPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.5; transform: scale(0.85); }
}

/* Login screen */
.af-login-shell {
  min-height: 100vh;
  display: grid; place-items: center;
  background:
    radial-gradient(ellipse 80% 55% at 50% 0%, rgba(21, 128, 61, 0.05), transparent 60%),
    radial-gradient(ellipse 60% 40% at 50% 100%, rgba(21, 128, 61, 0.03), transparent 60%),
    var(--surface-0);
  padding: 24px;
}
.af-login-card {
  width: 100%; max-width: 400px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px 32px 32px;
  box-shadow: var(--shadow-md);
  animation: loginIn 420ms var(--ease-out) both;
}
@keyframes loginIn {
  from { opacity: 0; transform: translateY(8px) scale(0.99); }
  to   { opacity: 1; transform: none; }
}
.af-login-card h1 {
  font-family: var(--font-display); font-weight: 400;
  font-size: 36px; letter-spacing: -0.02em;
  margin: 0 0 8px;
  line-height: 1.1;
  text-wrap: balance;
}
.af-login-card h1 span { color: var(--accent); }
.af-login-logo {
  display: block; height: 44px; width: auto;
  margin: 0 0 16px;
}
.af-login-card p.lede {
  color: var(--text-2); margin: 0 0 24px;
  font-size: 14px; line-height: 1.55;
  text-wrap: pretty;
}

/* Empty state */
.empty {
  padding: 72px 24px;
  text-align: center;
  color: var(--text-2);
  animation: fadeUp 280ms var(--ease-out) both;
}
.empty .head {
  font-family: var(--font-display); font-weight: 400;
  font-size: 32px; letter-spacing: -0.02em;
  color: var(--text-1); margin: 0 0 10px;
  line-height: 1.15;
  text-wrap: balance;
}
.empty .sub { font-size: 14px; color: var(--text-2); margin: 0 auto 24px; max-width: 420px; line-height: 1.55; text-wrap: pretty; }

/* Project chat side panel (opens from the right of the thumb grid) */
.project-chat-layout {
  display: grid; grid-template-columns: 1fr 400px;
  gap: 24px;
  min-height: calc(100vh - 180px);
}
.project-chat-panel {
  position: sticky; top: 76px;
  align-self: start;
  height: calc(100vh - 120px);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.project-chat-panel .head {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}
.project-chat-panel .head h2 { font-size: 14px; font-weight: 500; margin: 0; flex: 1; }
.project-chat-panel .body  { flex: 1; overflow: auto; padding: 12px 18px; display: flex; flex-direction: column; gap: 12px; }
.project-chat-panel .foot  { padding: 10px 14px; border-top: 1px solid var(--border); }
.project-chat-panel form { display: flex; gap: 8px; align-items: flex-end; }

/* Project grid */
.project-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.project-tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  cursor: pointer;
  position: relative;
  box-shadow: var(--shadow-xs);
  transition:
    border-color var(--dur-2) var(--ease),
    transform var(--dur-3) var(--ease-out),
    box-shadow var(--dur-3) var(--ease-out),
    background var(--dur-2) var(--ease);
  animation: tileIn 320ms var(--ease-out) both;
}
@keyframes tileIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
.project-tile:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.project-tile:active { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.project-tile h3 { font-size: 15px; font-weight: 500; margin: 0 0 8px; letter-spacing: -0.005em; line-height: 1.3; }
.project-tile .meta { display: flex; gap: 8px; color: var(--text-3); font-size: 12px; align-items: center; flex-wrap: wrap; }
.project-tile .meta .dot { width: 3px; height: 3px; background: var(--text-3); border-radius: 50%; opacity: 0.6; }

/* Plan editor */
.plan-list { list-style: none; padding: 0; margin: 0; }
.plan-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px; margin-bottom: 6px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  transition:
    border-color var(--dur-2) var(--ease),
    background var(--dur-2) var(--ease),
    box-shadow var(--dur-2) var(--ease),
    transform var(--dur-2) var(--ease);
}
.plan-row:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.plan-row.dragging { opacity: 0.5; transform: scale(0.98) rotate(-0.2deg); box-shadow: var(--shadow-md); }
.plan-row.drop-target { border-color: var(--accent); background: var(--accent-weak); box-shadow: 0 0 0 3px var(--accent-weak); }
.plan-grip {
  cursor: grab; color: var(--text-3);
  padding-top: 4px;
  user-select: none;
}
.plan-idx {
  font-family: var(--font-mono); font-size: 11px; color: var(--text-3);
  padding-top: 4px; min-width: 22px; text-align: right;
}
.plan-body { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.plan-title-input {
  background: transparent; border: 0; padding: 0;
  font-size: 14px; font-weight: 500; color: var(--text-1);
  width: 100%;
}
.plan-title-input:focus { outline: 0; }
.plan-purpose-input {
  background: transparent; border: 0; padding: 0;
  font-size: 13px; color: var(--text-2); line-height: 1.5;
  width: 100%; resize: none; font-family: inherit;
}
.plan-purpose-input:focus { outline: 0; color: var(--text-1); }
.plan-slug {
  font-family: var(--font-mono); font-size: 10px; color: var(--text-3);
  letter-spacing: 0;
}
.plan-remove {
  background: transparent; border: 0; color: var(--text-3);
  opacity: 0; transition: opacity 100ms var(--ease);
  padding: 4px 6px;
}
.plan-row:hover .plan-remove { opacity: 1; }
.plan-remove:hover { color: var(--danger); }

/* Chat */
.chat {
  display: flex; flex-direction: column;
  height: 100%;
  min-height: 0;
}
/* Collapsible history row at the top of the chat tab — always in
   reach for an "undo the last edit" action without tab-switching. */
.chat-history {
  border-bottom: 1px solid var(--border);
  padding: 4px 0;
}
.chat-history > summary {
  cursor: pointer;
  list-style: none;
  padding: 6px 4px;
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-2);
  user-select: none;
}
.chat-history > summary::-webkit-details-marker { display: none; }
.chat-history > summary .caret { transition: transform 120ms ease; display: inline-block; }
.chat-history[open] > summary .caret { transform: rotate(90deg); }
.chat-history > summary .icon { display: inline-flex; align-items: center; color: var(--text-2); }
.chat-history > summary .hint { color: var(--text-3); font-size: 11px; margin-left: auto; }
.chat-history-body {
  padding: 4px 0 10px;
  display: flex; flex-direction: column; gap: 4px;
}
.chat-history-row {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 6px;
  font-size: 12px;
  border-radius: 4px;
}
.chat-history-row[data-current="1"] { background: var(--surface-2); }
.chat-history-row .num { font-weight: 600; color: var(--text-1); min-width: 34px; }
.chat-history-row .when { color: var(--text-3); flex: 1; }
.chat-messages {
  flex: 1; overflow-y: auto;
  padding: 16px 0;
  display: flex; flex-direction: column; gap: 16px;
  scroll-behavior: smooth;
}
.chat-msg {
  display: flex; gap: 12px;
  animation: fadeUp 240ms var(--ease-out-expo) both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
.chat-msg .role {
  width: 40px; flex-shrink: 0; padding-top: 2px;
  font-family: var(--font-mono); font-size: 10px; color: var(--text-3);
  text-transform: uppercase;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-msg .content {
  flex: 1;
  font-size: 14px; line-height: 1.55; color: var(--text-1);
  white-space: pre-wrap; word-break: break-word;
  min-width: 0;
}
/* Markdown-rendered content (assistant replies). pre-wrap off because the
   markdown converter already produced <p>/<br>/<li> blocks. */
.chat-msg .content.md { white-space: normal; }
.chat-msg .content.md > :first-child { margin-top: 0; }
.chat-msg .content.md > :last-child  { margin-bottom: 0; }
.chat-msg .content.md p { margin: 0 0 10px; }
.chat-msg .content.md ul,
.chat-msg .content.md ol { margin: 6px 0 10px; padding-left: 22px; }
.chat-msg .content.md li { margin-bottom: 4px; }
.chat-msg .content.md li > p { margin: 0; }
.chat-msg .content.md h1,
.chat-msg .content.md h2,
.chat-msg .content.md h3,
.chat-msg .content.md h4 { font-size: 14px; font-weight: 600; margin: 12px 0 6px; }
.chat-msg .content.md strong { font-weight: 600; }
.chat-msg .content.md em { font-style: italic; }
.chat-msg .content.md hr { border: 0; border-top: 1px solid var(--border); margin: 12px 0; }
.chat-msg .content.md code {
  font-family: var(--font-mono); font-size: 12px;
  background: var(--surface-2); padding: 1px 5px; border-radius: 3px;
}
.chat-msg .content.md pre {
  background: var(--surface-2); padding: 10px 12px; border-radius: var(--radius);
  overflow-x: auto; margin: 8px 0;
}
.chat-msg .content.md pre code { background: transparent; padding: 0; }
.chat-msg.user .content { color: var(--text-2); }
.chat-msg .content.streaming::after {
  content: "▋"; display: inline-block; margin-left: 2px;
  animation: cursorBlink 1.1s var(--ease) infinite; color: var(--accent);
  font-weight: 400;
  vertical-align: -0.05em;
}
@keyframes blink { 50% { opacity: 0; } }
@keyframes cursorBlink {
  0%, 40%  { opacity: 1; }
  50%, 90% { opacity: 0.15; }
  100%     { opacity: 1; }
}

.chat-input {
  border-top: 1px solid var(--border);
  padding: 12px 0;
  display: flex; align-items: flex-end; gap: 8px;
}
.chat-input .textarea {
  border-radius: var(--radius-lg);
  min-height: 40px; max-height: 200px;
}

/* Project detail — two buckets side-by-side. Left = Details / Clarify,
   Right = Plan. Stacks on narrow screens. */
.proj-columns {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(0, 1.35fr);
  gap: 20px;
  align-items: start;
}
@media (max-width: 1100px) {
  .proj-columns { grid-template-columns: 1fr; }
}
.proj-col { min-width: 0; }

/* Small "Updated: brief + plan" chip under an assistant chat reply — tells
   the user their chat message produced a structural change. */
.chat-update-chip {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 6px; padding: 3px 10px 3px 8px;
  font-size: 11px; font-family: var(--font-mono);
  background: var(--accent-weak); color: var(--accent);
  border-radius: 999px;
  animation: chipIn 440ms var(--ease-out-back) both;
}
.chat-update-chip::before {
  content: '✓'; font-family: var(--font-sans); font-weight: 600;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: inline-grid; place-items: center;
  font-size: 9px;
  animation: checkIn 420ms var(--ease-out-back) 40ms both;
}
@keyframes chipIn {
  from { opacity: 0; transform: translateY(3px) scale(0.9); }
  to   { opacity: 1; transform: none; }
}
@keyframes checkIn {
  0%   { transform: scale(0.4); opacity: 0; }
  60%  { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); }
}

/* Post-commit chat hint — sits above the input divider. */
.chat-divider {
  margin: 4px 0 8px;
  padding: 6px 10px;
  font-size: 11px; color: var(--text-3);
  background: var(--surface-2);
  border-left: 2px solid var(--accent);
  border-radius: 3px;
}

/* Brief card — fills the right column, matches the chat height on the left.
   Body scrolls so the Save/Cancel footer stays visible. */
.plan-brief-card {
  height: calc(100vh - 200px);
  display: flex; flex-direction: column;
  padding: 0;
}
.plan-brief-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.plan-brief-head-row { display: flex; align-items: center; gap: 8px; }
.plan-brief-body {
  flex: 1; min-height: 0;
  overflow-y: auto;
  padding: 16px 18px;
}
.plan-brief-body .brief-ta {
  width: 100%; height: 100%;
  min-height: 200px;
  resize: none;
  font-family: var(--font-mono);
  font-size: 13px; line-height: 1.55;
}
.brief-preview {
  font-size: 14px; line-height: 1.6; color: var(--text-1);
}
.brief-preview > :first-child { margin-top: 0; }
.brief-preview p { margin: 0 0 10px; }
.brief-preview h1, .brief-preview h2, .brief-preview h3 { font-size: 14px; font-weight: 600; margin: 16px 0 6px; }
.brief-preview ul, .brief-preview ol { margin: 6px 0 10px; padding-left: 22px; }
.brief-preview li { margin-bottom: 4px; }
.brief-preview hr { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }
.brief-preview strong { font-weight: 600; }
.brief-preview code { font-family: var(--font-mono); font-size: 12px; background: var(--surface-2); padding: 1px 5px; border-radius: 3px; }
.plan-brief-foot {
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-1);
}
.plan-brief-mode { display: inline-flex; }
.plan-brief-mode .plan-subtabs { margin: 0; }

/* Segmented sub-tab pill used in both columns (Details/Clarify, Brief/Screens) */
.proj-subtabs,
.plan-subtabs {
  display: inline-flex; gap: 2px;
  padding: 3px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius);
  margin: 0 0 14px;
}
.proj-subtabs .sub-tab,
.plan-subtabs .sub-tab {
  border: 0; background: transparent;
  padding: 5px 12px; font-size: 12px; font-weight: 500;
  color: var(--text-2); border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color var(--dur-1) var(--ease), background var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}
.proj-subtabs .sub-tab:hover,
.plan-subtabs .sub-tab:hover { color: var(--text-1); }
.proj-subtabs .sub-tab:active,
.plan-subtabs .sub-tab:active { transform: scale(0.97); }
.proj-subtabs .sub-tab[data-active="1"],
.plan-subtabs .sub-tab[data-active="1"] {
  background: var(--surface-1); color: var(--text-1);
  box-shadow: 0 1px 2px rgba(23, 22, 20, 0.06), 0 1px 1px rgba(23, 22, 20, 0.04);
}

/* View bar — Grid/Prototype + viewport toggle */
.view-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 4px 0 16px;
}
.view-bar .seg {
  display: inline-flex; gap: 2px;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.view-bar .seg-btn {
  border: 0; background: transparent;
  padding: 5px 10px; font-size: 12px; font-weight: 500;
  color: var(--text-2); border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; gap: 4px;
  cursor: pointer;
  transition: color var(--dur-1) var(--ease), background var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease), transform var(--dur-1) var(--ease);
}
.view-bar .seg-btn:hover { color: var(--text-1); }
.view-bar .seg-btn:active { transform: scale(0.96); }
.view-bar .seg-btn[data-active="1"] {
  background: var(--surface-1);
  color: var(--text-1);
  box-shadow: 0 1px 2px rgba(23, 22, 20, 0.06), 0 1px 1px rgba(23, 22, 20, 0.04);
}
.view-bar .view-note { font-size: 12px; color: var(--text-3); }

/* Prototype view */
.prototype-view {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.prototype-frame {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  padding: 16px;
  display: grid; place-items: start center;
}
.prototype-view[data-viewport="mobile"] .prototype-frame {
  padding: 24px 16px;
}
.prototype-view[data-viewport="mobile"] .prototype-frame iframe {
  width: 390px; max-width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.prototype-view[data-viewport="desktop"] .prototype-frame iframe {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.prototype-frame iframe {
  height: 680px;
  background: #fff; border: 0; display: block;
}
.prototype-status {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  font-size: 12px; color: var(--text-3);
  padding: 0 4px;
}
.prototype-status .slug {
  font-family: var(--font-mono); color: var(--text-1);
}

/* Thumb grid */
.thumb-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.thumb {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition:
    border-color var(--dur-2) var(--ease),
    transform var(--dur-3) var(--ease-out),
    box-shadow var(--dur-3) var(--ease-out);
  display: flex; flex-direction: column;
  animation: tileIn 320ms var(--ease-out) both;
}
.thumb:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.thumb:active { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.thumb-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16/10;
  background: var(--surface-2);
  overflow: hidden;
}
/* Desktop thumb: iframe oversizes (500% wide) then scales back 0.2 so the
   rendered content fills the frame at a desktop viewport width. This is
   dimension-agnostic — works whatever the grid column width ends up being. */
.thumb-frame iframe {
  position: absolute; top: 0; left: 0;
  width: 500%; height: 500%;
  transform: scale(0.2); transform-origin: top left;
  border: 0; pointer-events: none;
  background: #fff;
}
/* Mobile thumb: the iframe renders at a fixed 390×780 phone viewport so the
   wireframe's `md:`/`lg:` rules fall back to the mobile layout. A container
   query scales that down to fit whatever thumb column ends up being. */
.thumb-grid[data-viewport="mobile"] .thumb-frame {
  aspect-ratio: 390 / 780;
  container-type: inline-size;
}
.thumb-grid[data-viewport="mobile"] .thumb-frame iframe {
  width: 390px; height: 780px;
  transform: scale(calc(100cqi / 390px));
  transform-origin: top left;
}
.thumb-frame .pending,
.thumb-frame .failed,
.thumb-frame .generating {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  padding: 24px; text-align: center;
  font-size: 12px; color: var(--text-3);
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}
.thumb-frame .failed { color: var(--danger); background: var(--danger-weak); }
.thumb-frame .pending {
  background:
    repeating-linear-gradient(135deg, var(--surface-2) 0 12px, var(--surface-3) 12px 13px);
}
.thumb-frame .generating {
  position: relative;
  background: var(--surface-2);
  color: var(--text-2);
  overflow: hidden;
}
.thumb-frame .generating::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(110deg,
    transparent 0%,
    transparent 30%,
    rgba(21, 128, 61, 0.08) 45%,
    rgba(21, 128, 61, 0.14) 50%,
    rgba(21, 128, 61, 0.08) 55%,
    transparent 70%,
    transparent 100%);
  background-size: 220% 100%;
  animation: shimmerSweep 1.6s var(--ease) infinite;
  pointer-events: none;
}
.thumb-frame .generating > span {
  position: relative;
  display: inline-flex; align-items: center; gap: 8px;
}
.thumb-frame .generating > span::before {
  content: ''; display: inline-block;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  animation: dotPulse 1.4s var(--ease) infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
@keyframes shimmerSweep {
  from { background-position: -60% 0; }
  to   { background-position: 160% 0; }
}
@keyframes dotPulse {
  0%, 100% { opacity: 1; transform: scale(1); box-shadow: 0 0 0 0 rgba(21, 128, 61, 0.4); }
  50%      { opacity: 0.6; transform: scale(0.85); box-shadow: 0 0 0 6px rgba(21, 128, 61, 0); }
}

.thumb-meta {
  padding: 10px 12px;
  display: flex; flex-direction: column; gap: 4px;
  border-top: 1px solid var(--border);
}
.thumb-meta .title { font-size: 13px; font-weight: 500; letter-spacing: -0.005em; }
.thumb-meta .sub { font-size: 11px; color: var(--text-3); font-family: var(--font-mono); }
.thumb-meta .status { display: flex; gap: 6px; align-items: center; margin-top: 2px; }

/* Screen detail — full-viewport split. No scrim; the wireframe IS the page. */
.screen-detail {
  position: fixed; inset: 0;
  background: var(--surface-0);
  z-index: 40;
  display: grid; grid-template-columns: 1fr 440px;
  animation: detailIn 240ms var(--ease-out-expo);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes detailIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.screen-detail .side { animation: detailSideIn 320ms var(--ease-out-expo) both; }
@keyframes detailSideIn {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: none; }
}
.screen-detail .preview {
  position: relative; overflow: auto;
  background: #fff;
}
.screen-detail .preview iframe {
  width: 100%; height: 100%; min-height: 100vh;
  background: #fff; border: 0; display: block;
}
/* Mobile viewport in the detail overlay — shrink iframe to phone width and
   centre it on a neutral backdrop so the reviewer sees the real mobile layout. */
.screen-detail .preview[data-viewport="mobile"] {
  background: var(--surface-2);
  display: grid; place-items: start center;
  padding: 24px 16px 32px;
}
.screen-detail .preview[data-viewport="mobile"] iframe {
  width: 390px; max-width: 100%;
  height: calc(100vh - 60px);
  min-height: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: #fff;
}
/* Top-right cluster on the detail preview: prev/next nav + viewport toggle. */
.detail-topbar-right {
  position: absolute; top: 12px; right: 12px; z-index: 46;
  display: inline-flex; gap: 8px;
  opacity: 0; pointer-events: none;
  transition: opacity 160ms var(--ease);
}

/* Invisible hover strip at the top of the preview that toggles the topbar
   controls. Height is generous so the mouse finds it easily; z-index sits
   below the buttons themselves but above the iframe so the hover registers. */
.screen-detail .preview .preview-topbar-sensor {
  position: absolute; top: 0; left: 0; right: 0; height: 60px;
  z-index: 45; background: transparent;
}

.screen-detail .preview .preview-topbar-sensor:hover ~ .close,
.screen-detail .preview .preview-topbar-sensor:hover ~ .detail-topbar-right,
.screen-detail .preview .close:hover,
.screen-detail .preview .detail-topbar-right:hover,
.screen-detail .preview .close:focus-visible,
.screen-detail .preview .detail-topbar-right:focus-within {
  opacity: 1; pointer-events: auto;
}
.detail-viewport-toggle,
.detail-nav-toggle {
  display: inline-flex; gap: 2px;
  padding: 3px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: saturate(160%) blur(8px);
  -webkit-backdrop-filter: saturate(160%) blur(8px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
}
.detail-viewport-toggle .seg-btn,
.detail-nav-toggle .seg-btn {
  border: 0; background: transparent;
  padding: 5px 8px; font-size: 12px;
  color: var(--text-3); border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; gap: 4px;
  cursor: pointer;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
}
.detail-viewport-toggle .seg-btn:hover,
.detail-nav-toggle .seg-btn:hover { color: var(--text-1); }
.detail-viewport-toggle .seg-btn:active,
.detail-nav-toggle .seg-btn:active { transform: scale(0.94); }
.detail-viewport-toggle .seg-btn[data-active="1"] {
  background: var(--accent); color: var(--accent-text);
  box-shadow: 0 1px 2px rgba(20, 83, 45, 0.28);
}
.detail-nav-toggle .seg-btn[disabled] {
  opacity: 0.35; cursor: default; pointer-events: none;
}
.screen-detail .preview .close {
  position: fixed; top: 12px; left: 12px; z-index: 46;
  border: 1px solid var(--border); background: rgba(255,255,255,0.92);
  backdrop-filter: saturate(160%) blur(8px);
  -webkit-backdrop-filter: saturate(160%) blur(8px);
  box-shadow: var(--shadow-sm);
  opacity: 0; pointer-events: none;
  transition: opacity 160ms var(--ease);
}
/* Floating hotspot tool in bottom-right of the preview pane */
.screen-detail .hotspot-fab {
  position: fixed; bottom: 20px; right: 460px; z-index: 45;
  display: flex; gap: 4px; align-items: center;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  box-shadow: var(--shadow-pop);
  animation: fabIn 340ms var(--ease-out-back) 80ms both;
}
@keyframes fabIn {
  from { opacity: 0; transform: translateY(8px) scale(0.96); }
  to   { opacity: 1; transform: none; }
}
.screen-detail .hotspot-fab button {
  border: 0; background: transparent; border-radius: 999px;
  padding: 6px 12px; font-size: 12px; font-weight: 500;
  display: inline-flex; gap: 6px; align-items: center;
  color: var(--text-2); cursor: pointer; white-space: nowrap;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
}
.screen-detail .hotspot-fab button:hover { background: var(--surface-2); color: var(--text-1); }
.screen-detail .hotspot-fab button:active { transform: scale(0.96); }
.screen-detail .hotspot-fab button[data-active="1"] {
  background: var(--accent); color: var(--accent-text);
  box-shadow: 0 1px 2px rgba(20, 83, 45, 0.24);
}
.screen-detail .hotspot-fab .dot {
  width: 9px; height: 9px; border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.6);
}
.screen-detail .hotspot-fab .dot.comment { background: var(--warn); }
.screen-detail .hotspot-fab .dot.edit    { background: #7c3aed; }
.screen-detail .hotspot-fab .dot.wysiwyg { background: #0ea5e9; }

.screen-detail .hotspot-fab.wysiwyg-bar { padding: 4px 6px 4px 12px; }
.screen-detail .hotspot-fab.wysiwyg-bar .wysiwyg-hint {
  font-size: 12px; color: var(--text-2); padding-right: 4px;
}
.screen-detail .hotspot-fab.wysiwyg-bar button.ghost {
  color: var(--text-2);
}
.screen-detail .hotspot-fab.wysiwyg-bar button.primary {
  background: var(--accent); color: var(--accent-text);
}
.screen-detail .hotspot-fab .kbd {
  font-family: var(--font-mono); font-size: 10px;
  padding: 1px 5px; border-radius: 3px;
  background: rgba(0,0,0,0.06); color: inherit;
  opacity: 0.7;
}
.screen-detail .hotspot-fab button[data-active="1"] .kbd {
  background: rgba(255,255,255,0.25);
}
.screen-detail .side {
  background: var(--surface-1);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  min-height: 0; height: 100vh;
}
.screen-detail .side .head {
  padding: 14px 20px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-1);
}
.screen-detail .side .head h2 {
  font-size: 15px; font-weight: 500; margin: 0;
  letter-spacing: -0.01em;
  color: var(--text-1);
  text-wrap: balance;
}
.screen-detail .side .head .sub {
  font-size: 11px; color: var(--text-3); font-family: var(--font-mono);
  margin-top: 4px;
  display: inline-flex; align-items: center; gap: 6px;
  letter-spacing: 0.01em;
}
.screen-detail .side .head .sub::after {
  content: ''; flex-shrink: 0;
  width: 3px; height: 3px; border-radius: 50%;
  background: var(--text-3); opacity: 0.5;
  display: none;
}
.screen-detail .side .tabs {
  display: flex; border-bottom: 1px solid var(--border);
  padding: 0 16px; gap: 4px;
}
.screen-detail .side .tab {
  padding: 10px 10px 12px;
  font-size: 12px; color: var(--text-3);
  background: transparent; border: 0; border-bottom: 2px solid transparent;
  margin-bottom: -1px; cursor: pointer;
  transition: color var(--dur-2) var(--ease), border-bottom-color var(--dur-2) var(--ease);
  letter-spacing: 0.01em;
}
.screen-detail .side .tab:hover { color: var(--text-1); }
.screen-detail .side .tab[data-active="1"] { color: var(--text-1); border-bottom-color: var(--accent); }
.screen-detail .side .body {
  flex: 1; min-height: 0; overflow: auto;
  padding: 14px 20px;
}
/* In the narrow side panel, the mono role column wastes horizontal width. */
.screen-detail .side .chat-msg { gap: 8px; }
.screen-detail .side .chat-msg .role {
  width: 28px; flex-shrink: 0;
  font-size: 9px; letter-spacing: 0.06em;
}

/* The Chat tab's composer/input is expected to be at the bottom, not floating. */
.screen-detail .side .chat { height: 100%; display: flex; flex-direction: column; min-height: 0; }
.screen-detail .side .chat-messages { flex: 1; overflow: auto; padding: 4px 0 8px; gap: 12px; }
.screen-detail .side .chat-empty-hint {
  padding: 24px 6px 8px;
  color: var(--text-2);
  line-height: 1.55;
  animation: fadeUp 260ms var(--ease-out-expo) both;
}
.screen-detail .side .chat-empty-title {
  font-size: 14px; font-weight: 500;
  color: var(--text-1);
  letter-spacing: -0.005em;
  margin-bottom: 4px;
}
.screen-detail .side .chat-empty-sub {
  font-size: 12.5px;
  color: var(--text-2);
  text-wrap: pretty;
}
.screen-detail .side .screen-chat-input {
  border-top: 1px solid var(--border);
  padding: 12px 18px 14px;
  background: var(--surface-1);
  margin: 0 -20px -14px; /* hug the side edges */
}
.screen-detail .side .screen-chat-input.drag-over {
  background: var(--accent-softer);
  box-shadow: inset 0 0 0 2px var(--accent);
}

/* Unified chat composer — matches the drawer composer. */
.screen-composer {
  display: flex; flex-direction: column;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: border-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
  overflow: hidden;
}
.screen-composer:focus-within {
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.screen-composer textarea {
  border: 0; background: transparent;
  padding: 10px 12px 8px;
  min-height: 60px; max-height: 200px;
  resize: none;
  font-size: 13.5px; line-height: 1.5;
  outline: 0; box-shadow: none;
  color: var(--text-1);
  font-family: inherit;
}
.screen-composer textarea::placeholder { color: var(--text-3); }
.screen-composer-atts,
.drawer-composer-atts {
  display: none;
  grid-template-columns: repeat(auto-fill, 52px);
  gap: 6px;
  padding: 8px 10px 0;
}
.screen-composer-foot {
  display: flex; align-items: center;
  gap: 6px;
  padding: 6px 6px 6px 6px;
  border-top: 1px solid var(--border);
  background: var(--surface-0);
}
.screen-composer-foot .kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
  margin-right: auto;
  padding-left: 4px;
}
.screen-composer-foot .kbd kbd {
  display: inline-block; padding: 1px 5px;
  border: 1px solid var(--border); border-bottom-width: 2px;
  border-radius: 3px;
  background: var(--surface-1);
  color: var(--text-2);
  font-family: inherit; font-size: 9px;
  line-height: 1.3;
}

.composer-icon-btn {
  width: 28px; height: 28px;
  padding: 0;
  display: inline-grid; place-items: center;
  border: 0; background: transparent;
  color: var(--text-3);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
}
.composer-icon-btn:hover { background: var(--surface-2); color: var(--text-1); }
.composer-icon-btn:active { transform: scale(0.92); }
.composer-icon-btn:focus-visible { outline: 0; box-shadow: var(--ring); }

.screen-att-chip {
  position: relative; width: 52px; height: 52px;
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden;
  animation: fadeUp 200ms var(--ease-out-back) both;
}
.screen-att-chip img { width: 100%; height: 100%; object-fit: cover; display: block; }
.screen-att-chip button {
  position: absolute; top: 3px; right: 3px;
  width: 16px; height: 16px; padding: 0;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(23, 22, 20, 0.75); color: #fff;
  border: 0; cursor: pointer;
  backdrop-filter: blur(4px);
  transition: background var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
}
.screen-att-chip button:hover { background: rgba(23, 22, 20, 0.95); }
.screen-att-chip button:active { transform: scale(0.88); }

/* Dropdown menu anchored to topbar "⋯" */
.af-menu {
  min-width: 240px;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 6px;
  box-shadow: var(--shadow-pop);
  animation: menuIn 180ms var(--ease-out-expo);
  transform-origin: top right;
}
@keyframes menuIn {
  from { opacity: 0; transform: translateY(-4px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}
.af-menu .item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: var(--radius);
  font-size: 13px; color: var(--text-1);
  cursor: pointer; background: transparent; border: 0;
  width: 100%; text-align: left;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.af-menu .item:hover { background: var(--surface-2); }
.af-menu .item:focus-visible { outline: 0; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--accent); }
.af-menu .item.danger { color: var(--danger); }
.af-menu .item.danger:hover { background: var(--danger-weak); }
.af-menu .item .sub { color: var(--text-3); font-size: 11px; margin-top: 2px; font-family: var(--font-mono); }
.af-menu .divider { height: 1px; background: var(--border); margin: 4px 0; }

/* Intent tag inside hotspot cards */
.hotspot-card[data-intent="edit"] { background: rgba(124, 58, 237, 0.08); color: var(--text-1); }
.hotspot-card[data-intent="edit"] .num { background: #7c3aed; }
.hotspot-card .intent-tag {
  display: inline-block; margin-right: 6px;
  font-size: 10px; font-family: var(--font-mono); text-transform: uppercase;
  padding: 1px 6px; border-radius: 3px;
  background: rgba(0,0,0,0.06); color: var(--text-2);
}
.hotspot-card[data-intent="edit"] .intent-tag { background: rgba(124,58,237,0.15); color: #5b21b6; }

/* Version list */
.version-row {
  display: flex; gap: 10px; padding: 10px; border-radius: var(--radius);
  font-size: 13px; align-items: center;
  transition: background var(--dur-1) var(--ease);
}
.version-row:hover { background: var(--surface-hover); }
.version-row[data-current="1"] {
  background: var(--accent-softer);
  box-shadow: inset 2px 0 0 var(--accent);
}
.version-row .num { font-family: var(--font-mono); font-size: 11px; color: var(--text-3); min-width: 28px; }
.version-row[data-current="1"] .num { color: var(--accent); font-weight: 500; }
.version-row .sub { font-size: 11px; color: var(--text-3); }

/* Hotspot tray */
.hotspot-tray { display: flex; flex-direction: column; gap: 8px; }
.hotspot-card {
  display: grid; grid-template-columns: 24px 1fr; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 13px;
  background: var(--warn-weak); color: var(--warn-text);
  animation: fadeUp 240ms var(--ease-out-expo) both;
  transition: transform var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}
.hotspot-card:hover { transform: translateX(1px); }
.hotspot-card.llm     { background: var(--surface-2); color: var(--text-2); }
.hotspot-card.edit    { background: #F3EEFE; color: #5B21B6; border-color: #DDD6FE; }
.hotspot-card.public  { background: var(--warn-weak); color: var(--warn-text); border-color: #FCD34D; }
.hotspot-card.archived { opacity: 0.55; }
.hotspot-card .num {
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  border-radius: 50%; width: 22px; height: 22px;
  display: grid; place-items: center;
  background: var(--warn); color: #fff;
}
.hotspot-card.llm  .num { background: var(--text-3); }
.hotspot-card.edit .num { background: #7c3aed; }
.hotspot-card .meta { display: flex; gap: 6px; align-items: center; margin-bottom: 2px; }
.hotspot-card .author { font-size: 10px; letter-spacing: 0.04em; font-family: var(--font-mono); text-transform: uppercase; opacity: 0.8; }
.hotspot-card .kind   { font-size: 10px; letter-spacing: 0.04em; font-family: var(--font-mono); text-transform: uppercase;
                        padding: 1px 6px; border-radius: 999px; background: rgba(0,0,0,0.05); }
.hotspot-card.edit .kind { background: rgba(124,58,237,0.14); }
.hotspot-card .body { line-height: 1.5; white-space: pre-wrap; }
.hotspot-card .body[contenteditable="true"] {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 6px 8px; outline: none;
}
.hotspot-card .actions { display: flex; gap: 4px; margin-top: 8px; flex-wrap: wrap; }
.hotspot-card .actions button {
  background: transparent; border: 1px solid transparent; color: inherit;
  opacity: 0.8;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease), opacity var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
}
.hotspot-card .actions button:hover { opacity: 1; background: rgba(0,0,0,0.06); }
.hotspot-card .actions button:active { transform: scale(0.96); }
.hotspot-card.edit .actions button:hover { background: rgba(124, 58, 237, 0.1); }
.hotspot-card.llm  .actions button:hover { background: rgba(0,0,0,0.05); }

/* Pending-edit badge on chat composer */
.pending-edits-banner {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: linear-gradient(180deg, #F7F2FE, #F3EEFE);
  color: #5B21B6;
  border: 1px solid #DDD6FE;
  border-radius: var(--radius);
  font-size: 12px;
  margin-bottom: 8px;
  box-shadow: 0 1px 2px rgba(124, 58, 237, 0.08);
  animation: fadeUp 220ms var(--ease-out-expo) both;
}
.pending-edits-banner .count {
  font-family: var(--font-mono); font-weight: 500;
  background: #7c3aed; color: #fff;
  padding: 1px 8px; border-radius: 999px;
  margin-right: 6px;
  box-shadow: 0 1px 2px rgba(124, 58, 237, 0.3);
}
.pending-edits-banner input[type="checkbox"] { accent-color: #7c3aed; }
.pending-edits-banner label {
  display: inline-flex; align-items: center; gap: 4px;
  cursor: pointer; line-height: 1.3;
}

/* Publish card */
.publish-box {
  background: linear-gradient(180deg, var(--accent-softer), var(--accent-weak));
  border: 1px solid rgba(21, 128, 61, 0.35);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  display: flex; align-items: center; gap: 12px;
  color: var(--accent);
  box-shadow: 0 1px 2px rgba(21, 128, 61, 0.08), inset 0 1px 0 rgba(255,255,255,0.4);
  animation: publishIn 520ms var(--ease-out-expo) both;
}
@keyframes publishIn {
  0%   { opacity: 0; transform: translateY(-6px) scale(0.99); box-shadow: 0 0 0 0 rgba(21, 128, 61, 0.32); }
  60%  {              box-shadow: 0 0 0 14px rgba(21, 128, 61, 0); }
  100% { opacity: 1; transform: none; box-shadow: 0 1px 2px rgba(21, 128, 61, 0.08), inset 0 1px 0 rgba(255,255,255,0.4); }
}
.publish-box .text { flex: 1; min-width: 0; }
.publish-box .text .url {
  font-family: var(--font-mono); font-size: 12px; word-break: break-all; color: var(--text-1);
  line-height: 1.45;
}
.publish-box .text .hint { font-size: 11px; color: var(--text-2); margin-top: 2px; }
.publish-box .actions { display: flex; gap: 6px; flex-shrink: 0; }

/* Modal — scrim itself scrolls so long modals (New project with viewport +
   "where does this live?" etc.) don't clip off the bottom. `safe center`
   falls back to flex-start when the modal is taller than the viewport, so
   the top of the modal stays reachable. */
.modal-scrim {
  position: fixed; inset: 0;
  background: rgba(14, 14, 14, 0.42);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: flex;
  align-items: safe center;
  justify-content: center;
  overflow-y: auto;
  padding: 24px;
  z-index: 60;
  animation: scrimIn 180ms var(--ease-out) both;
}
@keyframes scrimIn {
  from { opacity: 0; backdrop-filter: blur(0); -webkit-backdrop-filter: blur(0); }
  to   { opacity: 1; }
}
.modal {
  width: 100%; max-width: 520px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 24px;
  box-shadow: var(--shadow-lg);
  animation: modalIn 280ms var(--ease-out-expo) both;
  transform-origin: center;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}
.modal { position: relative; }
.modal h2 { font-size: 18px; font-weight: 500; margin: 0 0 4px; letter-spacing: -0.01em; text-wrap: balance; padding-right: 28px; }
.modal p.lede { color: var(--text-2); font-size: 13px; margin: 0 0 20px; line-height: 1.55; text-wrap: pretty; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
.modal .field { margin-bottom: 14px; }
.modal-close {
  position: absolute; top: 14px; right: 14px;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  background: transparent; border: 0;
  color: var(--text-3);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
}
.modal-close:hover { background: var(--surface-2); color: var(--text-1); }
.modal-close:active { transform: scale(0.92); }
.modal-close:focus-visible { outline: 0; box-shadow: var(--ring); }

/* Compact 2×2 picker grid. Each card is a tall pill with a bold label and
   one-line sub. Replaces the block-button pattern which stretched modals. */
.opt-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.opt-card {
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px 12px; min-height: 52px;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-1);
  color: var(--text-1);
  font-size: 13px; font-family: inherit;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition:
    border-color var(--dur-1) var(--ease),
    background var(--dur-1) var(--ease),
    transform var(--dur-1) var(--ease),
    box-shadow var(--dur-2) var(--ease);
}
.opt-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.opt-card:active { transform: scale(0.98); }
.opt-card:focus-visible { outline: 0; box-shadow: var(--ring); border-color: var(--accent); }
.opt-card[data-active="1"] {
  border-color: var(--accent);
  background: var(--accent-weak);
  box-shadow: 0 0 0 1px var(--accent), var(--shadow-xs);
}
.opt-card-label { font-weight: 500; line-height: 1.2; }
.opt-card-sub {
  font-size: 11px; color: var(--text-3);
  line-height: 1.3;
}
.opt-card[data-active="1"] .opt-card-sub { color: var(--accent); opacity: 0.85; }

/* Toast */
.toasts {
  position: fixed; bottom: 20px; right: 20px;
  display: flex; flex-direction: column-reverse; gap: 8px;
  z-index: 100;
  pointer-events: none;
}
.toast {
  background: #1C1917; color: #FAFAF9;
  padding: 10px 14px 10px 14px;
  border-radius: var(--radius-lg);
  font-size: 13px; line-height: 1.4;
  box-shadow: var(--shadow-pop), 0 0 0 1px rgba(255,255,255,0.04) inset;
  animation: toastIn 320ms var(--ease-out-expo) both;
  max-width: 340px;
  pointer-events: auto;
  letter-spacing: -0.005em;
  will-change: transform, opacity;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}
.toast.error { background: var(--danger); color: #fff; }
.toast.leaving { animation: toastOut 220ms var(--ease-out-expo) forwards; }
@keyframes toastOut {
  to { opacity: 0; transform: translateY(6px) scale(0.98); }
}

/* Copy button "copied" success state — brief accent bloom. */
.btn.copied {
  background: var(--accent-weak);
  border-color: rgba(21, 128, 61, 0.4);
  color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-weak), var(--shadow-xs);
}
.btn.copied svg { stroke: var(--accent); animation: checkDraw 360ms var(--ease-out-expo) both; }
@keyframes checkDraw {
  from { transform: scale(0.6); opacity: 0; }
  60%  { transform: scale(1.1); opacity: 1; }
  to   { transform: scale(1); opacity: 1; }
}

/* Stream cancel banner */
.stream-banner {
  position: fixed; bottom: 16px; left: 16px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius); padding: 6px 10px;
  font-size: 12px; color: var(--text-2);
  display: flex; align-items: center; gap: 8px;
  box-shadow: var(--shadow-pop);
  z-index: 100;
  animation: toastIn 280ms var(--ease-out-expo) both;
}
.stream-banner::before {
  content: ''; display: inline-block;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  animation: dotPulse 1.4s var(--ease) infinite;
}
.stream-banner .kbd {
  font-family: var(--font-mono);
  background: var(--surface-2);
  padding: 1px 5px; border-radius: 3px;
  color: var(--text-3);
}

/* Misc */
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.row { display: flex; gap: 8px; align-items: center; }
.col { display: flex; flex-direction: column; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.spacer-v { flex: 1; }

/* ── /create rework ────────────────────────────────────────────────── */

.af-topbar-compact { padding: 10px 24px; }
.af-topbar-compact h1 { font-size: 14px; }
.create-content { padding-bottom: 100px; }

/* Spec-chat drawer on /create uses the same chrome as the project-chat drawer
 * on /build. When open, the columns area yields ~400px to the drawer. */
.create-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: start;
}
.create-layout.with-drawer {
  grid-template-columns: 1fr 400px;
}
.create-primary { min-width: 0; }

/* Chat card fills the left column height. */
.chat-card {
  height: calc(100vh - 200px);
  display: flex; flex-direction: column;
  padding: 0;
}
.chat-card .chat {
  flex: 1; min-height: 0;
  padding: 0 18px 14px;
}
.chat-card .chat-messages { padding: 16px 0; }
.chat-card .chat-input {
  border-top: 1px solid var(--border);
  padding: 12px 18px 14px;
  margin: 0 -18px -14px;
  background: var(--surface-1);
  display: block;
}
.chat-card .chat-input.locked { opacity: 0.6; pointer-events: none; }
.chat-card .chat-input.locked textarea { cursor: not-allowed; }

/* Stepper at top of chat card. */
.chat-stepper {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-0);
  flex-wrap: nowrap;
  overflow-x: auto;     /* narrow widths: scroll horizontally, never wrap */
  scrollbar-width: none;
}
.chat-stepper::-webkit-scrollbar { display: none; }
.chat-stepper .step {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 10px;
  height: 26px;
  flex-shrink: 0;
  box-sizing: border-box;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 11.5px; font-weight: 500; color: var(--text-3);
  cursor: pointer;
  line-height: 1;
  transition:
    background var(--dur-2) var(--ease),
    color var(--dur-2) var(--ease),
    border-color var(--dur-2) var(--ease),
    transform var(--dur-1) var(--ease);
}
.chat-stepper .step:hover { color: var(--text-1); border-color: var(--border-strong); }
.chat-stepper .step:active { transform: scale(0.96); }
.chat-stepper .step .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--border-strong);
  flex: 0 0 6px;
  transition: background var(--dur-2) var(--ease);
}
.chat-stepper .step .label {
  margin: 0; line-height: 1; letter-spacing: 0.01em;
  white-space: nowrap;  /* 4-stage stepper was wrapping multi-word labels */
}
.chat-stepper .step.done {
  color: var(--text-1);
  background: var(--accent-weak);
  border-color: var(--accent-weak);
}
.chat-stepper .step.done .dot { background: var(--accent); }
.chat-stepper .step.current {
  color: var(--accent);
  background: var(--accent-weak);
  border-color: var(--accent);
}
.chat-stepper .step.current .dot {
  background: var(--accent);
  animation: dotPulse 1.6s var(--ease) infinite;
}
.chat-stepper .link {
  flex: 0 0 14px;
  height: 1px;
  background: var(--border-strong);
  align-self: center;
  opacity: 0.55;
}

/* Stage dividers inline in the chat timeline. */
.chat-stage-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 8px 0;
  color: var(--text-3);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  font-family: var(--font-mono);
}
.chat-stage-divider .line { flex: 1; height: 1px; background: var(--border); }
.chat-stage-divider .label { white-space: nowrap; }

/* Stage-indicator chip in the topbar. */
.af-topbar-project .chip.small { font-size: 10px; padding: 2px 6px; }

/* Create empty states inside cards. */
.create-empty { min-height: 200px; display: grid; place-items: center; }

/* Project chat drawer opens next to the primary content. */
.build-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: start;
}
.build-layout.with-drawer {
  grid-template-columns: 1fr 400px;
}
.build-primary { min-width: 0; }

.project-chat-drawer {
  position: sticky; top: 76px;
  align-self: start;
  height: calc(100vh - 100px);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  animation: drawerIn 280ms var(--ease-out-expo) both;
}
@keyframes drawerIn {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: none; }
}
.project-chat-drawer .head {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 12px 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-1);
}
.project-chat-drawer .head h2 {
  font-size: 13px; font-weight: 500; margin: 0;
  color: var(--text-1); letter-spacing: -0.005em;
}
.project-chat-drawer .head .drawer-new {
  padding: 5px 10px 5px 8px;
  font-size: 12px;
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--text-2);
}
.project-chat-drawer .head .drawer-close {
  width: 28px; height: 28px;
  display: inline-grid; place-items: center;
  padding: 0;
  color: var(--text-3);
}
.project-chat-drawer .head .drawer-close:hover { color: var(--text-1); }

.drawer-threads {
  padding: 4px;
  max-height: 32%; overflow: auto;
  border-bottom: 1px solid var(--border);
  background: var(--surface-0);
}
.drawer-thread-row {
  display: flex; width: 100%; text-align: left;
  align-items: flex-start; gap: 8px;
  padding: 7px 10px;
  background: transparent; border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  transition:
    background var(--dur-1) var(--ease),
    color var(--dur-1) var(--ease),
    transform var(--dur-1) var(--ease);
  color: var(--text-2);
}
.drawer-thread-row::before {
  content: '';
  flex-shrink: 0;
  width: 6px; height: 6px; border-radius: 50%;
  margin-top: 7px;
  background: var(--border-strong);
  transition: background var(--dur-1) var(--ease), transform var(--dur-2) var(--ease-out-back);
}
.drawer-thread-row:hover { background: var(--surface-hover); color: var(--text-1); }
.drawer-thread-row:hover::before { background: var(--text-3); }
.drawer-thread-row:active { transform: scale(0.99); }
.drawer-thread-row[data-active="1"] {
  background: var(--surface-2);
  color: var(--text-1);
}
.drawer-thread-row[data-active="1"]::before {
  background: var(--accent);
  transform: scale(1.2);
}
.drawer-thread-row .thread-col {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 1px;
}
.drawer-thread-row .title {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  color: inherit;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.drawer-thread-row .sub {
  font-size: 11px;
  color: var(--text-3);
  font-feature-settings: "tnum";
}

.drawer-messages {
  flex: 1; overflow: auto;
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.drawer-messages .hint,
.project-chat-drawer .drawer-messages > .empty {
  color: var(--text-3);
  font-size: 12px;
  text-align: center;
  padding: 20px 12px;
  line-height: 1.55;
}

/* Drawer composer — one unified rounded block with an inline Send. */
.drawer-input {
  padding: 12px 14px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface-1);
}
.drawer-composer {
  display: flex; flex-direction: column;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: border-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
  overflow: hidden;
}
.drawer-composer:focus-within {
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.drawer-composer textarea {
  border: 0; background: transparent;
  padding: 10px 12px 8px;
  min-height: 72px; max-height: 180px;
  resize: none;
  font-size: 13px; line-height: 1.5;
  outline: 0; box-shadow: none;
  color: var(--text-1);
}
.drawer-composer textarea::placeholder { color: var(--text-3); }
.drawer-composer-foot {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 6px;
  padding: 6px 6px 6px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface-0);
}
.drawer-composer-foot .kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
  margin-right: auto;
  letter-spacing: 0.02em;
}
.drawer-composer-foot .kbd kbd {
  display: inline-block; padding: 1px 5px;
  border: 1px solid var(--border); border-bottom-width: 2px;
  border-radius: 3px;
  background: var(--surface-1);
  color: var(--text-2);
  font-family: inherit; font-size: 9px;
  line-height: 1.3;
}
.drawer-send { padding: 5px 12px; font-size: 12px; }

/* ── Specs cards ───────────────────────────────────────────────────── */

.specs-card { padding: 0; }

/* Group headers ("Shared elements" / "Screens") inside the live specs
   list, so the user sees the two authoring phases visually. */
.specs-group-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 16px 14px 6px;
  border-top: 1px solid var(--border);
}
.specs-group-label:first-child { border-top: 0; padding-top: 8px; }
.specs-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.specs-head h2 { font-size: 15px; margin: 0 0 4px; }
.specs-status {
  padding: 8px 18px;
  background: var(--accent-weak); color: var(--accent);
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}
.specs-list {
  display: flex; flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  max-height: calc(100vh - 280px);
  overflow: auto;
}
.spec-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-1);
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  /* Parent is flex-column with a max-height; without this the 24 cards
     share the container height and get squashed down to the slug line,
     hiding the title + preview entirely. */
  flex-shrink: 0;
  transition:
    border-color var(--dur-2) var(--ease),
    box-shadow var(--dur-3) var(--ease-out),
    transform var(--dur-2) var(--ease);
}
.spec-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.spec-card[data-state="streaming"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-weak);
  position: relative; overflow: hidden;
}
.spec-card[data-state="streaming"]::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 40%, rgba(21, 128, 61, 0.08) 50%, transparent 60%);
  background-size: 200% 100%;
  animation: shimmerSweep 1.8s var(--ease) infinite;
  pointer-events: none;
}
.spec-card[data-state="failed"] { border-color: var(--danger); background: var(--danger-weak); }
.spec-card-head {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
}
.spec-card-head .spec-title-wrap { flex: 1; min-width: 0; }
.spec-slug {
  font-family: var(--font-mono); font-size: 10px;
  color: var(--text-3); text-transform: lowercase;
}
.spec-title {
  font-size: 13px; font-weight: 500; color: var(--text-1);
  margin-top: 2px;
}
/* Full-width block below the card head so the Regenerate button in the head
   row can't squeeze the summary into a narrow column. */
.spec-summary-block {
  padding: 0 14px 10px;
  border-top: 1px dashed var(--border-weak, rgba(0,0,0,0.08));
  margin-top: 2px;
  padding-top: 10px;
}
.spec-summary-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 4px;
}
.spec-summary {
  font-size: 12.5px; line-height: 1.55; color: var(--text-1);
  background: transparent;
  padding: 0;
  border: 0;
  border-radius: 0;
}
.spec-card-body {
  padding: 0 14px 12px;
}
.spec-card-body.collapsed .spec-preview {
  max-height: 120px; overflow: hidden;
  position: relative;
  mask-image: linear-gradient(180deg, #000 70%, transparent);
  -webkit-mask-image: linear-gradient(180deg, #000 70%, transparent);
}
.spec-card-body.expanded { padding-bottom: 14px; }
.spec-card-body .spec-expand { margin-top: 6px; }
.spec-preview {
  font-size: 12px; line-height: 1.5; color: var(--text-2);
}
.spec-preview h1, .spec-preview h2, .spec-preview h3 {
  font-size: 12px; font-weight: 600; margin: 8px 0 4px; color: var(--text-1);
}
.spec-preview p { margin: 0 0 6px; }
.spec-preview ul, .spec-preview ol { margin: 4px 0 6px; padding-left: 20px; }
.spec-preview li { margin-bottom: 2px; }
.spec-content .spec-edit-ta {
  font-family: var(--font-mono); font-size: 12px;
  min-height: 240px;
}
.spec-foot { margin-top: 8px; display: flex; gap: 8px; }

/* Screen detail Spec tab header row. */
.spec-detail-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px;
}
.spec-detail-head h3 { font-size: 13px; font-weight: 500; margin: 0; }

/* ── Bottom floating FAB ──────────────────────────────────────────── */

.create-fab {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 22px;
  font-size: 14px; font-weight: 500;
  letter-spacing: -0.005em;
  background: var(--accent); color: var(--accent-text);
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,0.1);
  z-index: 45;
  min-width: 220px;
  transition:
    background var(--dur-2) var(--ease),
    border-color var(--dur-2) var(--ease),
    box-shadow var(--dur-2) var(--ease),
    transform var(--dur-2) var(--ease-out),
    opacity var(--dur-2) var(--ease);
  cursor: pointer;
  animation: fabSlideUp 420ms var(--ease-out-expo) both;
  will-change: transform;
}
@keyframes fabSlideUp {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to   { opacity: 1; transform: translateX(-50%); }
}
.create-fab:hover:not([disabled]) {
  background: var(--accent-hover); border-color: var(--accent-hover);
  transform: translate(-50%, -1px);
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,0.1);
}
.create-fab:active:not([disabled]) {
  transform: translate(-50%, 0) scale(0.98);
  box-shadow: var(--shadow-xs), inset 0 1px 1px rgba(0,0,0,0.08);
  background: var(--accent-active); border-color: var(--accent-active);
}
.create-fab:focus-visible { outline: 0; box-shadow: var(--ring-offset); }
.create-fab[disabled] {
  background: var(--surface-1); color: var(--text-3);
  border-color: var(--border);
  box-shadow: var(--shadow-xs); cursor: not-allowed;
}
/* Ghost variant: used for "guidance" states (Fill out the Details tab /
   Use chat to share requirements) — clickable and moves the user forward,
   but visually subordinate to the primary-green "proceed" states so the
   moment to act on the actual forward step remains unmistakable. */
.create-fab.ghost {
  background: var(--surface-1); color: var(--text-2);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-xs);
}
.create-fab.ghost:hover:not([disabled]) {
  background: var(--surface-2); color: var(--text-1);
  border-color: var(--text-2);
  box-shadow: var(--shadow-sm);
}
.create-fab.ghost:active:not([disabled]) {
  background: var(--surface-2); color: var(--text-1);
}
.create-fab.loading::before {
  content: ''; display: inline-block;
  width: 12px; height: 12px; margin-right: 8px;
  border: 2px solid currentColor; border-top-color: transparent;
  border-radius: 50%; animation: spin 0.8s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Flow view (stacked screens + chat) ────────────────────────────── */

.flow-view { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.flow-hint {
  font-size: 12px; color: var(--text-3);
  padding: 8px 14px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.flow-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 12px;
  min-height: calc(100vh - 260px);
}
@media (max-width: 960px) {
  .flow-grid { grid-template-columns: 1fr; }
}

.flow-list {
  display: flex; flex-direction: column; gap: 6px;
  min-width: 0;
  align-self: start;
}

.flow-screen-row {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
.flow-screen-row[data-selected="1"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-softer);
}
.flow-screen-row[data-expanded="1"] { box-shadow: var(--shadow-xs); }

.flow-screen-head {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  background: transparent;
  border: 0;
  padding: 10px 14px;
  text-align: left;
  color: inherit;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--dur-1) var(--ease);
}
.flow-screen-head:hover { background: var(--surface-hover); }
.flow-screen-head .chev-wrap {
  display: inline-flex; width: 16px; height: 16px; align-items: center; justify-content: center;
  color: var(--text-3);
  transition: transform var(--dur-2) var(--ease);
}
.flow-screen-row[data-expanded="1"] .flow-screen-head .chev-wrap { transform: rotate(90deg); }
.flow-screen-title { font-weight: 500; color: var(--text-1); }
.flow-screen-slug { color: var(--text-3); font-size: 11px; }
.flow-screen-count { color: var(--text-3); font-size: 12px; }
.flow-screen-head .spacer-v { flex: 1; }

.flow-screen-body {
  padding: 6px 14px 12px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px;
}
.flow-tx-rows { display: flex; flex-direction: column; gap: 6px; }
.flow-tx-empty {
  padding: 10px; font-size: 12px; color: var(--text-3);
  background: var(--surface-2); border-radius: var(--radius);
  text-align: center;
}
.flow-tx-row {
  display: grid;
  grid-template-columns: minmax(200px, 1.6fr) minmax(90px, 0.8fr) minmax(160px, 1.4fr) auto;
  gap: 8px;
  align-items: end;
  padding: 8px; background: var(--surface-2);
  border-radius: var(--radius);
}
.flow-tx-cell { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.flow-tx-cell .micro {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-3);
}
.flow-tx-target { display: grid; grid-template-columns: 120px 1fr; gap: 6px; min-width: 0; }
.flow-tx-target .select,
.flow-tx-target .input { min-width: 0; width: 100%; }
.flow-tx-del { align-self: end; }

.flow-tx-foot {
  display: flex; align-items: center; gap: 8px;
  padding-top: 4px;
}
.flow-tx-foot .spacer-v { flex: 1; }

/* Right-side chat panel.
   Reuses the canonical .card.chat-card pattern for everything inside —
   message rows via AF.renderChatMessage, composer via .chat-input +
   .drawer-composer + kbd hint. The .flow-chat class only scopes the
   right-column sticky behaviour and the panel title block above the
   messages. */
.flow-chat {
  position: sticky; top: 84px;
  align-self: start;
  max-height: calc(100vh - 140px);
  height: auto;             /* override .chat-card's fixed height */
  overflow: hidden;
}
.flow-chat-head {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
}
.flow-chat-head-main { flex: 1; min-width: 0; }
.flow-chat-head h3 { margin: 0; font-size: 14px; font-weight: 500; }
.flow-chat-head .sub { margin: 2px 0 0; font-size: 12px; color: var(--text-3); }
/* Empty-state prompts inside the chat log keep the canonical .empty shape
   but add a compact example list below the sub copy. */
.flow-chat-empty ul { padding-left: 18px; margin: 10px 0 12px; color: var(--text-3); }
.flow-chat-empty li { margin: 4px 0; font-size: 12px; }

/* Screen-detail inline overlay Spec tab fit. */
.screen-detail .side .body .spec-detail-head .plan-subtabs { margin: 0; }

/* Mobile blocker — shown when viewport is too narrow / touch-only.
   Full-screen, non-dismissable. */
.mobile-blocker {
  position: fixed; inset: 0; z-index: 99999;
  background: var(--bg);
  display: grid; place-items: center;
  padding: 24px;
}
.mobile-blocker-card {
  max-width: 420px; width: 100%;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 32px 24px;
  text-align: center;
  box-shadow: var(--shadow-pop);
}
.mobile-blocker-brand {
  font-family: var(--font-display);
  font-size: 22px; font-weight: 700;
  color: var(--text-1); margin-bottom: 20px;
}
.mobile-blocker-brand span { color: var(--accent); }
.mobile-blocker-logo {
  display: block; height: 40px; width: auto;
  margin: 0 auto 20px;
}
.mobile-blocker-card h1 {
  font-size: 20px; margin: 0 0 12px; color: var(--text-1);
}
.mobile-blocker-card p {
  font-size: 14px; line-height: 1.5; color: var(--text-2);
  margin: 0 0 10px;
}
.mobile-blocker-card p.muted { color: var(--text-3); font-size: 13px; margin-top: 16px; }
