/* Project Dashboard — multi-project hub */

.pdb-app { display: grid; grid-template-columns: 232px minmax(0, 1fr); width: 100%; min-height: 100vh; background: var(--paper); }

/* Fluid main content: shrink with the window, never force overflow */
.pdb-main { min-width: 0; max-width: 100%; }

/* ─── App-level sidebar (NOT project-internal) ─── */
.pdb-sidebar {
  border-right: 1px solid var(--line);
  background: var(--paper);
  display: flex; flex-direction: column;
  padding: 18px 14px 14px;
  overflow: hidden;
}
.pdb-sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px 16px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 14px;
}
.pdb-sidebar .brand .mark {
  width: 26px; height: 26px; border-radius: 6px;
  background: var(--ink); color: var(--paper);
  display: grid; place-items: center;
  font-family: var(--serif); font-weight: 600; font-size: 15px;
}
.pdb-sidebar .brand .name { font-family: var(--serif); font-weight: 600; font-size: 17px; }
.pdb-sidebar .user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface);
  margin-bottom: 16px;
}
.pdb-sidebar .user .avatar {
  width: 26px; height: 26px; border-radius: 999px;
  background: var(--violet-soft); color: var(--violet-deep);
  display: grid; place-items: center;
  font-family: var(--serif); font-weight: 600; font-size: 12px;
}
.pdb-sidebar .user .meta { line-height: 1.2; }
.pdb-sidebar .user .nm { font-size: 13px; font-weight: 500; color: var(--ink); }
.pdb-sidebar .user .pl { font-size: 12px; color: var(--ink-4); }

.pdb-nav-group { margin-top: 8px; }
.pdb-nav-group-label {
  font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink-4); padding: 6px 10px 4px; font-weight: 600;
}
.pdb-nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 6px;
  font-size: 13px; color: var(--ink-2);
  cursor: pointer;
}
.pdb-nav-item:hover { background: var(--paper-2); }
.pdb-nav-item.active { background: var(--ink); color: var(--paper); }
.pdb-nav-item .count {
  margin-left: auto;
  font-family: var(--mono); font-size: 12px; color: var(--ink-4);
}
.pdb-nav-item.active .count { color: var(--paper); opacity: 0.65; }
.pdb-nav-item svg { opacity: 0.75; width: 15px; height: 15px; }
.pdb-nav-item.active svg { opacity: 1; }

/* ─── Main column ─── */
.pdb-main { display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: auto; }

.pdb-header {
  display: flex; align-items: end; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
  padding: 32px 40px 16px;
  border-bottom: 1px solid var(--line-soft);
}
.pdb-header h1 {
  font-family: var(--serif); font-weight: 600;
  font-size: 32px; letter-spacing: -0.025em; line-height: 1.1; margin: 0;
}
.pdb-header .sub {
  font-family: var(--serif); font-style: italic;
  font-size: 14.5px; color: var(--ink-3); margin-top: 6px;
}
.pdb-header .actions { display: flex; gap: 8px; align-items: center; }

/* Slim greeting banner */
.pdb-banner {
  display: flex; align-items: center; gap: 18px;
  padding: 12px 40px;
  background: var(--paper-2);
  border-bottom: 1px solid var(--line-soft);
  font-family: var(--mono); font-size: 12px; color: var(--ink-3);
  letter-spacing: 0.06em;
}
.pdb-banner .strong { color: var(--ink); font-weight: 500; }
.pdb-banner .pace { color: var(--ok); font-weight: 500; }
.pdb-banner .sep { color: var(--ink-5); }
.pdb-banner .grow { flex: 1; }

/* Filter bar */
.pdb-filters {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  padding: 14px 40px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--paper);
}
.pdb-search {
  display: flex; align-items: center; gap: 8px;
  flex: 1; max-width: 360px;
  height: 32px; padding: 0 10px;
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 6px;
  font-size: 13px; color: var(--ink-3);
}
.pdb-search .kbd {
  margin-left: auto;
  font-family: var(--mono); font-size: 12px;
  background: var(--paper-2); border: 1px solid var(--line-soft);
  padding: 1px 6px; border-radius: 3px;
  color: var(--ink-4);
}
.pdb-select {
  display: flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 10px;
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 6px;
  font-size: 12.5px; color: var(--ink-2);
}
.pdb-select .lbl { color: var(--ink-4); font-size: 12px; }

.pdb-seg {
  display: inline-flex; padding: 2px;
  background: var(--paper-2); border: 1px solid var(--line);
  border-radius: 6px;
  height: 32px; align-items: center;
}
.pdb-seg button {
  height: 24px; padding: 0 10px; border: 0; background: transparent;
  font-size: 12px; color: var(--ink-3); border-radius: 4px; font-weight: 500;
}
.pdb-seg button.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,0.04); }

.pdb-count {
  margin-left: auto;
  font-family: var(--mono); font-size: 12px; color: var(--ink-4);
  letter-spacing: 0.06em;
}

/* ─── Grid ─── */
.pdb-grid {
  padding: 24px 40px 60px;
  display: grid;
  /* Intrinsic fluid grid: auto-fits columns to available width with NO
     breakpoints. min(280px,100%) lets a lone column shrink below 280px
     instead of overflowing on very narrow screens. */
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: 16px;
  align-items: start;
}

/* ─── Project card ─── */
/* Layered paper-on-desk feel: thin top inner highlight, soft warm shadow,
   crisp 1px hairline around the edge. Lifts subtly on hover. */
.pdb-card {
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--surface);
  padding: 18px 20px 16px;
  display: flex; flex-direction: column;
  gap: 12px;
  position: relative;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.7) inset,
    0 1px 1px rgba(20,17,12,0.04),
    0 2px 4px rgba(20,17,12,0.05),
    0 8px 16px -8px rgba(20,17,12,0.08);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
  min-width: 0;
}
.pdb-card::before {
  /* paper-edge shadow line just below the top hairline */
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: 0 0 0 1px rgba(20,17,12,0.015);
}
.pdb-card:hover {
  transform: translateY(-2px);
  border-color: var(--ink-5);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.75) inset,
    0 2px 2px rgba(20,17,12,0.05),
    0 6px 10px rgba(20,17,12,0.07),
    0 18px 28px -10px rgba(20,17,12,0.12);
}
.pdb-card.archived {
  background: var(--paper-2);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.5) inset,
    0 1px 1px rgba(20,17,12,0.03),
    0 2px 4px rgba(20,17,12,0.04);
}
.pdb-card.archived h3 { color: var(--ink-3); }
.pdb-card.finished {
  background: var(--surface);
}

.pdb-card-row1 {
  display: flex; align-items: center; gap: 8px;
  min-width: 0;
}
.pdb-genre {
  display: inline-flex; align-items: center; height: 20px;
  padding: 0 9px; border-radius: 999px;
  background: var(--paper-2); border: 1px solid var(--line-soft);
  font-size: 12px; color: var(--ink-2); font-weight: 500;
  letter-spacing: 0.02em;
  /* shrink-to-fit with ellipsis so a long genre never widens row1 */
  flex: 0 1 auto; min-width: 0; max-width: 100%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pdb-status-dot {
  width: 7px; height: 7px; border-radius: 999px;
  background: var(--ok);
  flex-shrink: 0;
}
.pdb-status-dot.archived { background: var(--ink-5); }
.pdb-status-dot.finished { background: var(--violet); }
.pdb-status-text {
  font-family: var(--mono); font-size: 12px; color: var(--ink-4);
  letter-spacing: 0.1em; text-transform: uppercase;
}

.pdb-card .star, .pdb-card .kebab {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border: 0; background: transparent;
  border-radius: 5px; color: var(--ink-4);
}
.pdb-card .star:hover, .pdb-card .kebab:hover { background: var(--paper-2); color: var(--ink-2); }
.pdb-card .star.on { color: #C9A23F; }
.pdb-card .star.on svg { fill: #C9A23F; }

.pdb-card h3 {
  font-family: var(--serif); font-weight: 600;
  font-size: 21px; letter-spacing: -0.018em; line-height: 1.2;
  margin: 0; color: var(--ink);
  cursor: text;
}

.pdb-logline {
  font-family: var(--serif); font-style: italic;
  font-size: 15px; line-height: 1.5; color: var(--ink-3);
  margin: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
  text-wrap: pretty;
  cursor: text;
}

/* Stage pills */
.pdb-stages {
  /* Flex-wrap so 9 badges reflow to a second line on narrow viewports
     instead of squashing into fixed grid tracks that clip their text. */
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}
.pdb-stage {
  /* Box fits the text: content width + horizontal padding, never shrinks,
     never wraps mid-token. */
  flex: 0 0 auto;
  min-height: 22px;
  padding: 2px 6px;
  white-space: nowrap;
  border-radius: 4px;
  background: var(--paper-2);
  border: 1px solid var(--line-soft);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 12px;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-4);
  position: relative;
}
.pdb-stage .fill {
  position: absolute; inset: 0;
  background: var(--violet-soft);
  width: var(--p, 0%);
}
.pdb-stage .lbl { position: relative; z-index: 1; }
.pdb-stage[data-fill="1"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}
.pdb-stage[data-fill="1"] .fill { display: none; }
/* Counted PARTIAL (accent ramp): reduced-opacity accent + count -- distinct from
   dim (empty) and solid (full) by style, not by the number alone. */
.pdb-stage[data-state="partial"] {
  background: var(--violet-soft);
  border-color: var(--violet-soft);
  color: var(--ink-2);
  font-size: 10px;
}

/* Revision runs the SUCCESS (green) ramp -- same size + link as the others; the
   hue signals coverage (in_percent:false), not score. Same tri-state shape. */
.pdb-stage[data-ramp="success"][data-state="empty"] {
  background: transparent; border-color: #BBF7D0; color: var(--ink-4);
}
.pdb-stage[data-ramp="success"][data-state="partial"] {
  background: #DCFCE7; border-color: #86EFAC; color: #15803D; font-size: 10px;
}
.pdb-stage[data-ramp="success"][data-fill="1"] {
  background: #16A34A; border-color: #16A34A; color: #FFFFFF;
}

/* Percent bar (backend `percent`). Estimated -> hatched fill (see data-est). */
.pdb-bar {
  flex: 1; height: 6px; min-width: 40px; max-width: 130px;
  border-radius: 999px; background: var(--line-soft); overflow: hidden;
}
.pdb-bar-fill { display: block; height: 100%; background: var(--ink); border-radius: 999px; }
.pdb-bar[data-est="1"] .pdb-bar-fill {
  background-color: var(--violet-soft);
  background-image: repeating-linear-gradient(45deg, var(--ink-4) 0, var(--ink-4) 3px, transparent 3px, transparent 7px);
}

.pdb-meta {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--mono); font-size: 12px;
  color: var(--ink-4); letter-spacing: 0.06em;
}
.pdb-meta .sep { color: var(--ink-5); }
.pdb-meta .pct { color: var(--ink-2); font-weight: 500; }

/* "Start new story" tile */
.pdb-newtile {
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #8B5CF6 0%, #F59E0B 100%);
  padding: 28px 24px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px;
  min-height: 100%;
  color: #FFFFFF;
  cursor: pointer;
  transition: filter .14s;
}
.pdb-newtile:hover {
  filter: brightness(1.05);
}
.pdb-newtile .plus {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  color: #FFFFFF;
}
.pdb-newtile .plus svg { stroke: #FFFFFF; }
.pdb-newtile .ttl {
  font-family: var(--serif); font-weight: 600;
  font-size: 17px; color: #FFFFFF; letter-spacing: -0.01em;
}
.pdb-newtile .sub {
  font-size: 12px; color: rgba(255, 255, 255, 0.85);
  text-align: center; max-width: 200px; line-height: 1.4;
}

/* Buttons reused */
.pdb-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 14px;
  border-radius: 6px; border: 1px solid var(--line);
  background: var(--surface); font-size: 13px; color: var(--ink); font-weight: 500;
}
.pdb-btn:hover { background: var(--paper-2); }
.pdb-btn.primary {
  background: var(--ink); color: var(--paper); border-color: var(--ink);
}
.pdb-btn.primary:hover { background: var(--ink-2); }
.pdb-btn.violet { background: var(--violet); color: white; border-color: var(--violet); }
.pdb-btn.violet:hover { background: var(--violet-deep); border-color: var(--violet-deep); }

/* ─── Mobile ─── */
.dm-shell {
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  background: var(--paper); overflow: hidden;
}
.dm-status {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 18px 4px; font-size: 12px; font-weight: 600;
}
.dm-top {
  padding: 12px 18px 14px;
  border-bottom: 1px solid var(--line);
}
.dm-top .h1 {
  font-family: var(--serif); font-weight: 600;
  font-size: 22px; letter-spacing: -0.02em; line-height: 1.15;
}
.dm-top .sub {
  font-family: var(--serif); font-style: italic;
  font-size: 12.5px; color: var(--ink-3); margin-top: 4px;
}
.dm-top .banner {
  display: flex; gap: 10px; align-items: center;
  margin-top: 12px; padding: 8px 10px;
  background: var(--paper-2); border-radius: 6px;
  font-family: var(--mono); font-size: 12px; color: var(--ink-3);
  letter-spacing: 0.06em;
}
.dm-top .banner .strong { color: var(--ink); font-weight: 500; }

.dm-filters {
  display: flex; gap: 8px; padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
  overflow-x: auto;
}
.dm-filters .chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 28px; padding: 0 10px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  font-size: 12px; color: var(--ink-2); white-space: nowrap;
  flex-shrink: 0;
}
.dm-filters .chip.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.dm-grid {
  flex: 1; min-height: 0; overflow: auto;
  padding: 12px 14px 24px;
  display: flex; flex-direction: column; gap: 10px;
}
.dm-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  padding: 14px 14px 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.dm-card .row1 { display: flex; align-items: center; gap: 6px; }
.dm-card h3 {
  font-family: var(--serif); font-weight: 600;
  font-size: 16px; letter-spacing: -0.01em; line-height: 1.2;
  margin: 0;
}
.dm-card .logline {
  font-family: var(--serif); font-style: italic;
  font-size: 12.5px; line-height: 1.45; color: var(--ink-3);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0;
}
.dm-card .stages {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px;
}
.dm-card .stages .s {
  height: 5px; border-radius: 999px;
  background: var(--paper-3);
  position: relative; overflow: hidden;
}
.dm-card .stages .s .f {
  position: absolute; inset: 0;
  background: var(--violet);
}
.dm-card .stages .s.full .f { background: var(--ink); width: 100%; }
.dm-card .meta {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 12px; color: var(--ink-4);
  letter-spacing: 0.06em;
}

/* Reasoning + canvas */
.pa-artboard-shell {
  width: 100%; height: 100%; overflow: hidden;
  background: var(--paper);
  font-family: var(--sans);
}
.pa-mobile-shell {
  width: 100%; height: 100%;
  border: 1px solid var(--line);
  border-radius: 32px;
  background: var(--paper);
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(20,17,12,0.06);
}
.pa-reasoning {
  font-family: var(--serif);
  max-width: 760px;
  padding: 24px 28px 8px;
  color: var(--ink-2);
}
.pa-reasoning h2 { font-family: var(--serif); font-weight: 600; font-size: 22px; margin: 6px 0 10px; color: var(--ink); }
.pa-reasoning p { font-size: 15.5px; line-height: 1.55; margin: 0 0 10px; }
.pa-reasoning ul { font-size: 14px; line-height: 1.55; padding-left: 18px; }
.pa-reasoning li { margin-bottom: 6px; }
.pa-reasoning .intent { font-weight: 600; color: var(--ink); }
.pa-reasoning .eyebrow { display: block; margin-bottom: 4px; font-family: var(--sans); }

/* ─── Phase 6 additions — production wiring ──────────────────────────────────
   All rules below are additive. Nothing above is modified.                   */

/* Utility ------------------------------------------------------------------ */
.hidden { display: none !important; }

/* Disabled nav item (Templates — Phase 2 will unlock) ---------------------- */
.pdb-nav-item-disabled { opacity: 0.38; cursor: not-allowed; pointer-events: none; }

/* Stage pills -- anchor element reset (sizing + wrap live in the .pdb-stage block) */
a.pdb-stage { text-decoration: none; color: var(--ink-4); }
a.pdb-stage[data-fill="1"] { color: var(--paper); }

/* Search — real <input> replaces static label span ------------------------- */
.pdb-search input[type="text"] {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink-2);
  outline: none;
  min-width: 0;
}
.pdb-search input[type="text"]::placeholder { color: var(--ink-4); }

/* Genre — invisible <select> overlaid on .pdb-select wrapper --------------- */
.pdb-select { position: relative; cursor: pointer; }
.pdb-genre-select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border: none;
  background: transparent;
  appearance: none;
  -webkit-appearance: none;
}

/* Kebab dropdown panel ----------------------------------------------------- */
.pdb-card-row1 { position: relative; }
.pdb-kebab-panel {
  position: absolute;
  top: calc(100% + 2px);
  right: 0;
  z-index: 50;
  min-width: 160px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 4px 12px rgba(20, 17, 12, 0.10);
  border-radius: var(--rad-sm);
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.pdb-kebab-panel button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 6px 10px;
  border: none;
  background: transparent;
  font-size: 13px;
  color: var(--ink);
  border-radius: 3px;
  cursor: pointer;
}
.pdb-kebab-panel button:hover { background: var(--paper-2); }
.pdb-kebab-panel button.danger { color: var(--bad); }
.pdb-kebab-panel button.danger:hover { background: var(--paper-2); }

/* Save-status indicator (below title and logline) -------------------------- */
.pdb-save-indicator {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-4);
  letter-spacing: 0.04em;
}

/* Card body — JS handles navigation, not native pointer -------------------- */
.pdb-card[data-card-link] { cursor: default; }

/* Sidebar nav count badges (Phase 7.5) */
.pdb-nav-count {
  margin-left: auto; font-family: var(--mono); font-size: 12px;
  color: var(--ink-4); background: var(--paper-2);
  padding: 1px 6px; border-radius: 4px; min-width: 18px; text-align: center;
}
.pdb-nav-item.active .pdb-nav-count { background: var(--ink-3); color: var(--paper); }
.pdb-nav-count:empty { display: none; }

/* Responsive drawer chrome — hamburger + scrim (hidden on desktop) */
.nav-toggle {
  display: none;
  position: fixed;
  top: 12px; left: 12px;
  z-index: 60;
  width: 40px; height: 40px;
  align-items: center; justify-content: center;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  color: var(--ink-2);
  cursor: pointer;
}
.nav-scrim {
  display: none;
  position: fixed; inset: 0;
  background: rgba(20,17,12,0.32);
  z-index: 40;
}

/* Single shell mode-switch: sidebar becomes an off-canvas drawer.
   The card grid stays fully fluid at ALL widths (no column-count overrides). */
@media (max-width: 899px) {
  .pdb-app { grid-template-columns: 1fr; }
  .nav-toggle { display: flex; }
  .pdb-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 248px;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: 0 0 40px rgba(20,17,12,0.18);
  }
  body.nav-open .pdb-sidebar { transform: translateX(0); }
  body.nav-open .nav-scrim { display: block; }
  .pdb-header { flex-direction: column; align-items: flex-start; gap: 8px; padding: 18px 16px 12px 64px; }
  .pdb-banner { padding: 10px 16px; flex-wrap: wrap; gap: 8px; }
  .pdb-filters { padding: 12px 16px; flex-wrap: wrap; gap: 8px; }
  .pdb-search { flex: 1 1 100%; max-width: 100%; }
  .pdb-count { margin-left: 0; }
  /* keep grid fluid; only trim side padding on small screens */
  .pdb-grid { padding: 16px 16px 40px; }
}
