/* The workspace pages: rail, context, reports, people. */

.app {
  display: grid;
  grid-template-columns: 16rem minmax(0, 1fr) 19rem;
  gap: clamp(1rem, 2.5vw, var(--s-6));
  align-items: start;
  padding-top: calc(3.9rem + var(--s-5));
  padding-bottom: var(--s-9);
}
@media (max-width: 1180px) { .app { grid-template-columns: 15rem minmax(0, 1fr); } .aside { display: none; } }
@media (max-width: 880px) { .app { grid-template-columns: minmax(0, 1fr); padding-top: calc(3.6rem + var(--s-4)); } }

/* A scroller must never widen the column it sits in. */
.rail, .main, .aside { min-width: 0; }
.rail > *, .rail-list { min-width: 0; }

/* ---- Rail -------------------------------------------------------------- */

.rail { position: sticky; top: calc(3.9rem + var(--s-4)); display: flex; flex-direction: column; gap: var(--s-5); }
@media (max-width: 880px) { .rail { position: static; } }

.rail h4, .aside h4 {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 0 0 var(--s-2);
  padding-inline: 0.6rem;
}

.rail-list { display: flex; flex-direction: column; gap: 2px; }
@media (max-width: 880px) {
  /* On a phone the rooms become a single swipe, not a stacked list. */
  .rail-list {
    flex-direction: row;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    padding-bottom: var(--s-2);
    scrollbar-width: none;
  }
  .rail-list::-webkit-scrollbar { display: none; }
  .rail-item { scroll-snap-align: start; white-space: nowrap; }
  .rail-item .count { margin-left: var(--s-2); }
}

.rail-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.6rem;
  border-radius: var(--r-md);
  font-size: 0.92rem;
  color: var(--text-2);
  transition: background var(--t-hover) var(--ease), color var(--t-hover) var(--ease), transform var(--t-press) var(--ease);
}
.rail-item:hover { background: var(--glass-light); }
.rail-item:active { transform: scale(0.98); }
.rail-item[aria-current="true"] { background: var(--surface-2); color: var(--text); }
.rail-item .tick { width: 3px; height: 1.1rem; border-radius: 3px; background: transparent; flex: none; margin-left: -0.35rem; }
.rail-item[aria-current="true"] .tick { background: var(--edge, var(--accent)); }
.rail-item .count { margin-left: auto; font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-3); }

/* ---- Main column ------------------------------------------------------- */

.main { min-width: 0; display: flex; flex-direction: column; gap: var(--s-5); }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; }
.page-head h1 { font-family: var(--font-head); font-size: clamp(1.7rem, 3vw, 2.3rem); line-height: 1.1; letter-spacing: -0.022em; }
.crumb { font-family: var(--font-mono); font-size: 0.74rem; color: var(--text-3); margin-bottom: 0.4rem; }

/* Segmented control. The thumb travels; it does not blink from tab to tab. */
.seg {
  position: relative;
  display: inline-flex;
  padding: 3px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.seg .thumb {
  position: absolute;
  top: 3px; left: 3px;
  height: calc(100% - 6px);
  border-radius: var(--r-full);
  background: var(--surface-3);
  box-shadow: var(--shadow-sm);
  transform: translate3d(var(--seg-x, 0px), 0, 0);
  width: var(--seg-w, 0px);
  transition: none;
}
.seg button {
  position: relative;
  z-index: 1;
  padding: 0.35rem 0.85rem;
  border-radius: var(--r-full);
  font-size: 0.85rem;
  color: var(--text-2);
  transition: color var(--t-hover) var(--ease);
}
.seg button[aria-selected="true"] { color: var(--text); }

/* ---- Context document -------------------------------------------------- */

.doc {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
}
.doc-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s-2) var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  position: sticky;
  top: 3.9rem;
  z-index: 5;
}
.doc-body { padding: var(--s-5) clamp(1rem, 3vw, var(--s-6)); }
.doc-body h2 {
  font-family: var(--font-head);
  font-size: 1.32rem;
  line-height: 1.25;
  letter-spacing: -0.016em;
  margin: var(--s-6) 0 var(--s-3);
  font-weight: 500;
}
.doc-body h2:first-child { margin-top: 0; }
.doc-body p, .doc-body li { color: var(--text-2); font-size: 0.96rem; line-height: 1.65; max-width: 68ch; }
.doc-body ul { margin: 0 0 var(--s-4); padding-left: 1.1rem; }
.doc-body li { margin-bottom: 0.35rem; }
.doc-body code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--glass-light);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.1em 0.35em;
  color: var(--text);
}
.doc-body strong { color: var(--text); font-weight: 500; }

/* A decision, its why, and who stands behind it. */
.decision {
  border-left: 2px solid var(--line-strong);
  padding: 0.15rem 0 0.15rem var(--s-4);
  margin: var(--s-4) 0;
  transition: background var(--t-hover) var(--ease);
}
.decision:hover { background: var(--glass-light); }
.decision .what { color: var(--text); font-size: 1rem; margin-bottom: 0.3rem; }
.decision .why { color: var(--text-2); font-size: 0.92rem; margin: 0 0 0.45rem; }
.decision .by { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-3); }

/* ---- Report cards ------------------------------------------------------ */

.report {
  display: grid;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  transition: border-color var(--t-hover) var(--ease), opacity 260ms var(--ease),
              transform 320ms var(--ease), height 320ms var(--ease), margin 320ms var(--ease),
              padding 320ms var(--ease);
  will-change: transform;
}
.report { --hue: var(--pending); }
.report[data-state="approved"] { --hue: var(--ok); }
.report[data-state="rejected"] { --hue: var(--drift); }
.report:hover { box-shadow: var(--lift-quiet); }
.report[data-settled="true"] { opacity: 0; transform: scale(0.97); pointer-events: none; overflow: hidden; }
.report .head { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.report .subject { font-family: var(--font-head); font-size: 1.08rem; letter-spacing: -0.012em; font-weight: 500; }
.report .what { color: var(--text-2); font-size: 0.94rem; line-height: 1.55; margin: 0; }
.report .why { color: var(--text-3); font-size: 0.88rem; line-height: 1.55; margin: 0; padding-left: var(--s-3); border-left: 1px solid var(--line); }
.report .foot { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.report .foot .spacer { flex: 1; }

.avatar {
  width: 1.5rem; height: 1.5rem;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text-invert);
  background: var(--accent);
  flex: none;
}
.avatar-lg { width: 2.2rem; height: 2.2rem; font-size: 0.8rem; }


/* ---- Tinted panels ------------------------------------------------------
   A card that says something about state wears that state's colour, lightly,
   so a glance down the page finds it without reading. */

.card[data-tint] {
  background: color-mix(in oklab, var(--tint) 9%, var(--surface));
  border-color: transparent;
}
.card[data-tint] .card-title { color: color-mix(in oklab, var(--tint) 62%, var(--text)); }
.card[data-tint="pending"] { --tint: var(--pending); }
.card[data-tint="accent"] { --tint: var(--accent); }
.card[data-tint="ok"] { --tint: var(--ok); }

/* A report wears the colour of its verdict on its left edge: thin, and mixed
   back toward the card so it marks the row without shouting across it. */
.report { position: relative; overflow: hidden; }
.report::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: color-mix(in oklab, var(--hue) 62%, var(--surface));
}
.report[data-settled="true"]::before { opacity: 0; }

/* ---- Agent tiles ------------------------------------------------------- */

.agent.tile {
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-5);
  min-height: 12rem;
}
.agent .chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.22rem 0.6rem;
  border-radius: var(--r-full);
  background: rgba(255, 255, 255, 0.6);
  font-size: 0.76rem;
  color: var(--ink);
}
.agent .chip .dot { width: 6px; height: 6px; border-radius: 50%; background: #b7791f; }
.agent .chip .dot[data-fresh="true"] { background: #1f9d63; }
.agent .name {
  display: block;
  font-family: var(--font-head);
  font-size: 1.15rem;
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--ink);
}
.agent .meta { display: block; margin-top: 0.15rem; font-size: 0.86rem; color: var(--ink-2); }
.agent .rooms { display: block; margin-top: 0.5rem; font-family: var(--font-mono); font-size: 0.72rem; color: var(--ink-2); }

/* ---- Aside ------------------------------------------------------------- */

.aside { position: sticky; top: calc(3.9rem + var(--s-4)); display: flex; flex-direction: column; gap: var(--s-5); }

.feed { display: flex; flex-direction: column; }
.feed-item {
  display: grid;
  grid-template-columns: 1.5rem 1fr;
  gap: var(--s-3);
  padding: 0.6rem 0.6rem 0.6rem 0;
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--text-2);
  position: relative;
}
.feed-item::before {
  content: "";
  position: absolute;
  left: 0.72rem; top: 2rem; bottom: -0.2rem;
  width: 1px;
  background: var(--line);
}
.feed-item:last-child::before { display: none; }
.feed-item b { color: var(--text); font-weight: 450; }
.feed-item .when { display: block; font-family: var(--font-mono); font-size: 0.7rem; color: var(--text-3); margin-top: 0.15rem; }

/* ---- People ------------------------------------------------------------ */

.person { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-4) var(--s-5); }
.person .who { min-width: 0; }
.person .who .n { display: block; font-size: 0.98rem; line-height: 1.2; }
.person .who .e { display: block; font-size: 0.82rem; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; }
.person .scopes { margin-left: auto; display: flex; gap: 0.35rem; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 640px) {
  .person { flex-wrap: wrap; }
  .person .scopes { margin-left: 2.9rem; width: 100%; justify-content: flex-start; }
}

/* ---- Command palette --------------------------------------------------- */

.palette {
  position: fixed;
  z-index: 95;
  top: clamp(3rem, 12vh, 7rem);
  left: 50%;
  width: min(38rem, calc(100vw - 2rem));
  transform: translate3d(-50%, 0, 0) scale(0.96);
  opacity: 0;
  visibility: hidden;
  transform-origin: top center;
  background: var(--glass);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border: 1px solid var(--glass-edge);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transition: opacity 180ms var(--ease), transform 260ms var(--ease), visibility 0s linear 260ms,
              backdrop-filter 260ms var(--ease);
}
.palette[data-open="true"] {
  opacity: 1;
  visibility: visible;
  transform: translate3d(-50%, 0, 0) scale(1);
  transition-delay: 0s;
}
.palette input {
  width: 100%;
  padding: var(--s-4) var(--s-5);
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line);
  font-size: 1rem;
  outline: none;
}
.palette input::placeholder { color: var(--text-3); }
.palette-list { max-height: min(22rem, 50vh); overflow-y: auto; padding: var(--s-2); }
.palette-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  padding: 0.6rem 0.75rem;
  border-radius: var(--r-md);
  font-size: 0.93rem;
  color: var(--text-2);
  text-align: left;
}
.palette-item[data-active="true"] { background: var(--glass-light); }
.palette-item .where { margin-left: auto; font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-3); }
.palette-empty { padding: var(--s-5); text-align: center; color: var(--text-3); font-size: 0.9rem; }

/* A search field that looks like the button it replaces on a phone. */
.search-trigger {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-width: 13rem;
  padding: 0.5rem 0.85rem;
  border-radius: var(--r-full);
  border: 0;
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 0.88rem;
  transition: background var(--t-hover) var(--ease), color var(--t-hover) var(--ease);
}
.search-trigger:hover { background: var(--surface-3); }
.search-trigger .k {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0.05rem 0.3rem;
}
/* Below 1100px the bar runs out of room for the words, so the field shrinks to
   its icon first; the links and the way in stay on one line. */
@media (max-width: 1100px) { .search-trigger { min-width: 0; } .search-trigger .t, .search-trigger .k { display: none; } }
