/* WeBuilt Founder OS — application shell around the Calling Desk.
   Builds only on the Calling Desk tokens (tokens.css) and Theme v2 in app.css:
   navy sidebar, blue active state, panels, pills and buttons. Adds the
   Conversations nav group, the Studly column and the phone tab bar. */

:root {
  --studly-w: 360px;
  --tabbar-h: 64px;
}

/* ------------------------------------------------------- sidebar nav ---- */
.sidebar .nav {
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--navy-line) transparent;
  margin-bottom: var(--space-3);
}
.nav-group {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--navy-ink);
  font: inherit;
  font-weight: 500;
  font-size: var(--fs-body);
  text-align: left;
  cursor: pointer;
}
.nav-group svg {
  flex: none;
  color: var(--navy-muted);
}
.nav-group:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}
.nav-group:hover svg,
.nav-group.has-current,
.nav-group.has-current svg {
  color: #fff;
}
.nav-chev {
  margin-left: auto;
  display: inline-flex;
  transition: transform 160ms ease;
}
.nav-group[aria-expanded='true'] .nav-chev {
  transform: rotate(180deg);
}
.nav-sub {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 2px 0 4px 19px;
  padding-left: 8px;
  border-left: 1px solid var(--navy-line);
}
.nav .nav-sub a {
  padding: 7px 10px;
  font-size: var(--fs-dense);
}

/* ---------------------------------------------------------- page head ---- */
.page-eyebrow {
  margin-bottom: 2px;
  color: var(--blue-strong);
  font-size: var(--fs-meta);
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.studly-toggle {
  flex: none;
}
.studly-toggle svg {
  color: var(--blue);
}
.shell.studly-open .studly-toggle {
  background: var(--blue-subtle);
  border-color: var(--blue-line);
  color: var(--blue-strong);
}

/* Conversations views as a scrolling strip when the sidebar is a drawer. */
.subnav {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 0 var(--space-5) var(--space-2);
  scrollbar-width: none;
}
.subnav a {
  flex: none;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-size: var(--fs-dense);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.subnav a[aria-current='page'] {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}
@media (min-width: 1024px) {
  .subnav {
    display: none !important;
  }
}

/* ----------------------------------------------------------- scrims ---- */
.nav-scrim,
.studly-scrim {
  display: none;
}
@media (max-width: 1023px) {
  .shell.nav-open .nav-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 49;
    background: rgba(15, 23, 42, 0.28);
  }
}

/* ------------------------------------------------------------ Studly ---- */
.studly {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--surface);
  border-left: 1px solid var(--line);
}
.studly-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px var(--space-3);
  padding: var(--space-5) var(--space-5) var(--space-3);
}
.studly-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--blue-subtle);
  color: var(--blue);
}
.studly-title h2 {
  font-size: var(--fs-section);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.studly-title p {
  color: var(--muted);
  font-size: var(--fs-meta);
}
.studly-close {
  grid-column: 3;
  grid-row: 1;
}
.studly-status {
  grid-column: 2 / 4;
  justify-self: start;
}
.studly-tabs {
  display: flex;
  gap: var(--space-5);
  padding: 0 var(--space-5);
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-dense);
  font-weight: 600;
  color: var(--muted);
}
.studly-tabs span {
  padding: 8px 0 10px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.studly-tabs .is-current {
  color: var(--ink-2);
  border-bottom-color: var(--line);
}
.studly-body {
  flex: 1;
  overflow: auto;
  padding: var(--space-4) var(--space-5);
  display: grid;
  gap: var(--space-3);
  align-content: start;
}
.studly-notice {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px dashed var(--blue-line);
  background: var(--blue-subtle);
  font-size: var(--fs-dense);
  color: var(--ink-2);
}
.studly-notice strong {
  display: block;
  color: var(--ink);
  margin-bottom: 2px;
}
.studly-label {
  margin-top: var(--space-2);
  color: var(--muted);
  font-size: var(--fs-meta);
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.studly-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
}
.studly-actions .btn {
  justify-content: center;
  white-space: normal;
  height: auto;
  min-height: 34px;
  padding-top: 6px;
  padding-bottom: 6px;
  line-height: 1.3;
}
.studly-preview {
  display: grid;
  gap: var(--space-3);
  opacity: 0.7;
}
.studly-bubble {
  display: grid;
  gap: 6px;
  width: 82%;
  padding: 12px;
  border-radius: 12px;
  background: var(--surface-sunken);
}
.studly-bubble.is-me {
  justify-self: end;
  width: 60%;
  background: var(--blue-subtle);
}
.studly-bubble i {
  display: block;
  height: 8px;
  border-radius: 4px;
  background: var(--line);
}
.studly-bubble.is-me i {
  background: var(--blue-line);
}
.studly-compose {
  padding: var(--space-3) var(--space-5) var(--space-4);
  border-top: 1px solid var(--line-soft);
}
.studly-input-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.studly-input-row .textarea {
  flex: 1;
  min-width: 0;
  height: 38px;
  min-height: 38px;
  padding-top: 8px;
  padding-bottom: 8px;
  resize: none;
}
.studly-foot {
  margin-top: 6px;
  color: var(--muted);
  font-size: var(--fs-meta);
}

/* Wide screens: Studly is the third column, open by default. */
@media (min-width: 1440px) {
  .shell.studly-open {
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--studly-w);
  }
  .studly {
    position: sticky;
    top: 0;
    height: 100vh;
  }
  /* The content column is narrower with Studly docked: use the layouts the
     Calling Desk already has for that width. */
  .shell.studly-open .desk {
    grid-template-columns: minmax(240px, 280px) minmax(0, 1fr);
  }
  .shell.studly-open .desk-context {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .shell.studly-open .desk.in-call {
    grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  }
  .shell.studly-open .desk.in-call .desk-queue {
    display: none;
  }
  .shell.studly-open .desk.in-call .desk-context {
    grid-column: auto;
    grid-template-columns: minmax(0, 1fr);
  }
  .shell.studly-open .metric-band {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .shell.studly-open .metric:nth-child(4) {
    border-left: 0;
  }
  .shell.studly-open .metric:nth-child(n + 4) {
    border-top: 1px solid var(--line-soft);
  }
  .shell.studly-open .conv-layout {
    grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  }
  .shell.studly-open .conv-side {
    display: none;
  }
}

/* Smaller screens: Studly opens over the page. */
@media (max-width: 1439px) {
  .studly {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(400px, 100vw);
    z-index: 56;
    box-shadow: var(--overlay-shadow);
  }
  .shell.studly-open .studly-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(15, 23, 42, 0.28);
  }
}

/* ------------------------------------------------------ phone tab bar ---- */
.tabbar {
  display: none;
}
@media (max-width: 767px) {
  .btn.menu-btn,
  .studly-toggle {
    display: none !important;
  }
  .main {
    padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  }
  .subnav {
    padding: 0 var(--space-4) var(--space-2);
  }
  .toast {
    bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom, 0px));
  }
  .studly {
    width: 100vw;
    border-left: 0;
  }
  .tabbar {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: rgba(255, 255, 255, 0.97);
    border-top: 1px solid var(--line);
    backdrop-filter: saturate(1.2) blur(8px);
  }
  .tabbar-item,
  .tabbar-studly {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 0;
    border: 0;
    background: none;
    font: inherit;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
    cursor: pointer;
  }
  .tabbar-item[aria-current='page'],
  .tabbar-item.is-current {
    color: var(--blue);
  }
  .tabbar-studly {
    justify-content: flex-end;
    padding-bottom: 8px;
    color: var(--ink-2);
  }
  .tabbar-studly-orb {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    margin-top: -26px;
    border-radius: 50%;
    border: 4px solid var(--canvas);
    background: linear-gradient(180deg, #3b6cf5 0%, var(--blue-strong) 100%);
    color: #fff;
    box-shadow: 0 8px 20px rgba(43, 92, 240, 0.35);
  }
  .tabbar :focus-visible {
    box-shadow: var(--focus);
    border-radius: 10px;
  }
}

/* --------------------------------------------- new Founder OS sections ---- */
.fos-today-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.fos-today {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: var(--space-4);
}
.fos-today > .fos-card {
  grid-column: span 3;
}
.fos-today > .fos-briefing {
  grid-column: span 4;
}
.fos-today > .fos-action-card {
  grid-column: span 2;
}
.fos-today > .fos-span-all {
  grid-column: 1 / -1;
}
.fos-meta {
  color: var(--muted);
  font-size: var(--fs-meta);
  white-space: nowrap;
}
.fos-note {
  color: var(--muted);
  font-size: var(--fs-dense);
}
.fos-error {
  color: var(--amber);
  display: flex;
  gap: 6px;
  align-items: flex-start;
  margin-top: var(--space-2);
}
.fos-bullets {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.fos-bullet {
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-size: var(--fs-body);
  color: var(--ink-2);
}
.fos-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  transform: translateY(-1px);
}
.fos-bullet.is-good .fos-dot {
  background: var(--green);
}
.fos-bullet.is-warn .fos-dot {
  background: var(--amber);
}
.fos-bullet.is-neutral .fos-dot {
  background: var(--blue);
}
.fos-action {
  display: grid;
  gap: var(--space-2);
  justify-items: start;
}
.fos-action h3 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.fos-action-detail {
  color: var(--ink-2);
  font-size: var(--fs-dense);
}
.fos-action .btn-block {
  width: 100%;
  justify-content: center;
  margin-top: var(--space-2);
}
.fos-rule {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: var(--fs-meta);
}
.fos-rows {
  display: grid;
  margin: calc(var(--space-2) * -1) calc(var(--space-3) * -1);
}
.fos-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-3);
  border-radius: 10px;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}
.fos-row + .fos-row {
  border-top: 1px solid var(--line-soft);
}
.fos-row:hover {
  background: var(--surface-sunken);
}
.fos-tag {
  flex: none;
  min-width: 52px;
  color: var(--blue-strong);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.fos-row-main {
  display: grid;
  min-width: 0;
  flex: 1;
}
.fos-row-main strong,
.fos-row-main span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fos-row-main strong {
  font-weight: 600;
  font-size: var(--fs-body);
}
.fos-row-main span {
  color: var(--muted);
  font-size: var(--fs-meta);
}
.fos-row-when {
  flex: none;
  color: var(--muted);
  font-size: var(--fs-meta);
}
.fos-row-go {
  flex: none;
  display: inline-flex;
  color: var(--muted);
  transform: rotate(-90deg);
}
.fos-pulse {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-5);
}
.fos-pulse-col h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-body);
  font-weight: 650;
  margin-bottom: var(--space-3);
}
.fos-pulse-col h3 svg {
  color: var(--blue);
}
.fos-pulse-col + .fos-pulse-col {
  border-left: 1px solid var(--line-soft);
  padding-left: var(--space-5);
}
.fos-stats {
  display: grid;
  gap: 8px;
}
.fos-stat {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 8px;
  font-size: var(--fs-dense);
  color: var(--ink-2);
}
.fos-stat .mono {
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.fos-pulse-foot {
  margin-top: var(--space-4);
}
.fos-planned {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
  margin: var(--space-4) 0 0;
  padding: 0;
  list-style: none;
}
.fos-planned li {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-sunken);
  color: var(--ink-2);
  font-size: var(--fs-meta);
  font-weight: 550;
}
@media (max-width: 1199px) {
  .fos-today > .fos-briefing,
  .fos-today > .fos-action-card {
    grid-column: span 3;
  }
  .fos-pulse {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .fos-pulse-col:nth-child(3) {
    border-left: 0;
    padding-left: 0;
  }
}
@media (max-width: 899px) {
  .fos-today {
    grid-template-columns: minmax(0, 1fr);
  }
  .fos-today > .fos-card,
  .fos-today > .fos-briefing,
  .fos-today > .fos-action-card {
    grid-column: 1 / -1;
  }
  .fos-pulse {
    grid-template-columns: minmax(0, 1fr);
  }
  .fos-pulse-col + .fos-pulse-col {
    border-left: 0;
    padding-left: 0;
    border-top: 1px solid var(--line-soft);
    padding-top: var(--space-4);
  }
}

/* Decisions */
.dec-list { margin: 0; padding-left: 20px; display: grid; gap: 4px; overflow-wrap: anywhere; }

/* Company, Product, Growth and Operations records */
.rec-title { margin: 0; font-size: 16px; overflow-wrap: anywhere; }
.rec-card.is-archived { opacity: 0.75; }
.rec-fields { margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px 16px; }
.rec-fields > div { min-width: 0; }
.rec-fields dt { font-size: 12px; color: var(--ink-3, var(--ink-2)); }
.rec-fields dd { margin: 0; overflow-wrap: anywhere; }
.rec-long { white-space: pre-wrap; overflow-wrap: anywhere; }
.rec-long .hint { display: block; }
.rec-status { width: auto; max-width: 100%; }
.rec-stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
a.fos-pulse-link { display: block; color: inherit; text-decoration: none; }
a.fos-pulse-link:hover .mono { color: var(--blue); }
.fos-stat.is-bad .mono { color: var(--bad, #b42318); }
.fos-pulse + .fos-pulse { margin-top: var(--space-5); padding-top: var(--space-5); border-top: 1px solid var(--line-soft); }
