/*
  The ZenAI page (D1, TO-55): every brief, grouped by report, with its filters. Not connected it is
  a full-area screen; connected it is master-detail, the briefs beside the one being read (Ro,
  5 Nov 2026). The reading pane uses the drawer's brief card, so hosts link zen-drawer.css too.

  Its own stylesheet, like zen-drawer.css. The page carries .tomo-face, so every token below (and
  the dark palette) comes from tomo-face.css. Nothing here invents a colour. One centred column,
  as the chat has it (Ro, 23 Oct 2026); inside it, each brief is the kit's collapsible row
  (TomoCollapsibleRow, Ro, 26 Oct 2026): compact collapsed, the detail on expand, one list at every
  width, the same pattern as Connections and Settings. The row's own styles are in tomo-face.css.

  Hosts include it after tomo-face.css:
    <link rel="stylesheet" href="_content/Tomo.Face/zen-page.css" />
*/

.zen-page.tomo-face {
  display: block;
  background: var(--tomo-canvas);
  color: var(--tomo-text-primary);
}

.zen-page__column {
  box-sizing: border-box;
  width: min(100% - 32px, clamp(720px, 62vw, 1080px));
  margin: 0 auto;
  padding: var(--tomo-space-6) 0 var(--tomo-space-8);
}

.zen-page__top { margin-bottom: var(--tomo-space-4); }

/*
  The ZenAI page itself (Ro, 5 Nov 2026): it covers the host's content area. --zen-page-min-height
  is how tall the area is; a host with a taller or shorter top bar sets it on the page's parent.
*/
.zen-page--hero.tomo-face,
.zen-page--split.tomo-face {
  box-sizing: border-box;
  min-height: var(--zen-page-min-height, calc(100dvh - 140px));
  overflow-x: clip; /* clip, not hidden: hidden makes a scroll box and the reading pane would never stick */
}

/* The split answers to the page's own width, not the window's: a host's side nav takes some.
   Named, because the row list is its own (narrow) container and an unnamed query would ask it. */
.zen-page--split.tomo-face { container: zen-page / inline-size; }

/* ---------- Connected: list | reading pane ---------- */

.zen-page__frame {
  box-sizing: border-box;
  width: min(100% - 32px, 1440px);
  margin: 0 auto;
  padding: var(--tomo-space-6) 0 var(--tomo-space-8);
}

.zen-page__split {
  display: grid;
  grid-template-columns: minmax(360px, 480px) minmax(0, 1fr);
  gap: var(--tomo-space-6);
  align-items: start;
}

.zen-page__split--solo { grid-template-columns: minmax(0, 1fr); }
.zen-page__split--solo .zen-page__list { width: min(100%, 760px); }

.zen-page__list { min-width: 0; }

/* The reading pane: a surface beside the list, its own scroll, the chat's centred column inside. */
.zen-page__reader {
  position: sticky;
  top: var(--tomo-space-4);
  box-sizing: border-box;
  max-height: calc(100dvh - 120px);
  overflow-x: hidden;
  overflow-y: auto;
  padding: var(--tomo-space-6) var(--tomo-space-8);
  border: 1px solid var(--tomo-border-light);
  border-radius: var(--tomo-radius-lg);
  background: var(--tomo-surface);
  box-shadow: var(--tomo-shadow-sm);
}

/* One centred ~740px column, as the chat has it (Ro, 5 Nov 2026); fluid below 740. */
.zen-page__readcol {
  box-sizing: border-box;
  width: 100%;
  max-width: 740px;
  margin-inline: auto;
}
.zen-page__readcol .zen-brief { padding-top: 0; border-top: 0; }

.zen-page__readacts {
  display: flex;
  gap: var(--tomo-space-2);
  margin-top: var(--tomo-space-4);
  padding-top: var(--tomo-space-4);
  border-top: 1px solid var(--tomo-border-subtle);
}

.zen-page__readacts .tomo-btn { min-height: 32px; padding: 0 var(--tomo-space-3); font-size: 13px; }

.zen-page__readhidden { margin: var(--tomo-space-2) 0 0; font-size: 14px; color: var(--tomo-text-muted); }

/* The row being read: an accent edge, so the eye joins the list to the pane. Only beside the pane. */
@container zen-page (min-width: 1024px) {
  .zen-page__split:not(.zen-page__split--solo) .tomo-crow[data-selected="true"] {
    border-color: var(--tomo-accent);
    box-shadow: inset 3px 0 0 var(--tomo-accent);
  }
}

@container zen-page (max-width: 1023px) {
  .zen-page__split { grid-template-columns: minmax(0, 1fr); }
  .zen-page__reader { display: none; }
  .zen-page__list { width: min(100%, 760px); margin: 0 auto; }
}

/* ---------- Not connected: the full-area screen ---------- */

.zen-page--hero.tomo-face {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--tomo-space-12) var(--tomo-space-6);
  background:
    radial-gradient(60% 70% at 85% 30%, var(--tomo-accent-subtle), transparent 70%),
    radial-gradient(40% 50% at 10% 90%, var(--tomo-sovereign-subtle), transparent 70%),
    var(--tomo-canvas);
}

.zen-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: var(--tomo-space-12);
  align-items: center;
  width: min(100%, 1120px);
}

.zen-hero__copy { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; }

.zen-hero__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--tomo-space-2);
  padding: 4px 12px 4px 6px;
  border: 1px solid var(--tomo-border-light);
  border-radius: var(--tomo-radius-full);
  background: var(--tomo-surface);
  font-size: 13px;
  font-weight: 700;
  color: var(--tomo-text-primary);
}

.zen-hero__mark { width: 20px; height: 20px; }

.zen-hero__title {
  margin: var(--tomo-space-4) 0 0;
  max-width: 20ch;
  font-size: 40px;
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.025em;
  color: var(--tomo-text-primary);
}

.zen-hero__lede {
  margin: var(--tomo-space-3) 0 0;
  max-width: 52ch;
  font-size: 16px;
  line-height: 1.55;
  color: var(--tomo-text-secondary);
}

.zen-hero__benefits {
  display: flex;
  flex-direction: column;
  gap: var(--tomo-space-4);
  margin: var(--tomo-space-8) 0 0;
  padding: 0;
  list-style: none;
}

.zen-hero__benefit { display: flex; gap: var(--tomo-space-3); align-items: flex-start; }

.zen-hero__icon {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--tomo-radius-md);
  background: var(--tomo-accent-subtle);
  color: var(--tomo-accent);
}

.zen-hero__btext { display: flex; flex-direction: column; gap: 2px; font-size: 14px; line-height: 1.45; }
.zen-hero__btext strong { font-weight: 700; color: var(--tomo-text-primary); }
.zen-hero__btext span { color: var(--tomo-text-secondary); }

.zen-hero__problem {
  display: flex;
  gap: var(--tomo-space-3);
  align-items: flex-start;
  box-sizing: border-box;
  width: min(100%, 480px);
  margin: var(--tomo-space-6) 0 0;
  padding: var(--tomo-space-3) var(--tomo-space-4);
  border: 1px solid var(--tomo-danger-line);
  border-radius: var(--tomo-radius-md);
  background: var(--tomo-danger-bg);
  font-size: 13.5px;
  line-height: 1.45;
}

.zen-hero__problem > span:last-child { display: flex; flex-direction: column; gap: 2px; }
.zen-hero__problem strong { color: var(--tomo-danger-ink); }
.zen-hero__problem span span { color: var(--tomo-text-secondary); }
.zen-hero__problem .tomo-failure__glyph { font-weight: 800; line-height: 1.45; }

.zen-hero__cta { display: flex; flex-direction: column; align-items: flex-start; gap: var(--tomo-space-2); margin-top: var(--tomo-space-8); }
.zen-hero__problem + .zen-hero__cta { margin-top: var(--tomo-space-4); }

.zen-hero__connect {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--tomo-space-2);
  min-height: 44px;
  min-width: 180px;
  padding: 0 var(--tomo-space-6);
  border-radius: var(--tomo-radius-full);
  font-size: 15px;
}

.zen-hero__connect:focus-visible { outline: 3px solid var(--tomo-accent); outline-offset: 3px; }
.zen-hero__connect:disabled { opacity: 0.8; cursor: progress; }

.zen-hero__spin {
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: zen-hero-spin 0.8s linear infinite;
}

@keyframes zen-hero-spin { to { transform: rotate(360deg); } }

.zen-hero__micro { margin: 0; font-size: 13px; color: var(--tomo-text-muted); }

/* The decorative brief: shapes, no figures, labelled Example. Hidden from readers. */
.zen-hero__preview { position: relative; min-width: 0; padding: var(--tomo-space-6) var(--tomo-space-4) var(--tomo-space-8) 0; }

.zen-hero__sample {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: var(--tomo-space-3);
  padding: var(--tomo-space-6);
  border: 1px solid var(--tomo-border-light);
  border-radius: var(--tomo-radius-xl);
  background: var(--tomo-surface-elevated);
  box-shadow: var(--tomo-shadow-lg);
  transform: rotate(-1.5deg);
}

.zen-hero__sample--behind {
  position: absolute;
  inset: var(--tomo-space-12) 0 0 var(--tomo-space-8);
  z-index: 0;
  min-height: 0;
  background: var(--tomo-surface);
  box-shadow: var(--tomo-shadow-md);
  opacity: 0.7;
  transform: rotate(3deg);
}

.zen-hero__samplehead { display: flex; align-items: center; gap: var(--tomo-space-2); font-size: 12px; }

.zen-hero__sampletile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--tomo-radius-sm);
  background: var(--tomo-accent-subtle);
  color: var(--tomo-accent);
}

.zen-hero__samplelabel { font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--tomo-text-muted); }
.zen-hero__samplewhen { margin-left: auto; color: var(--tomo-text-muted); }

.zen-hero__bar { display: block; height: 10px; border-radius: var(--tomo-radius-full); background: var(--tomo-border-light); }
.zen-hero__bar--head { width: 88%; height: 16px; background: var(--tomo-border-strong); }
.zen-hero__bar--line { width: 100%; }
.zen-hero__bar--short { width: 62%; }

.zen-hero__chart { width: 100%; height: 72px; margin-top: var(--tomo-space-1); }
.zen-hero__area { fill: var(--tomo-accent-subtle); }
.zen-hero__line { fill: none; stroke: var(--tomo-accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }

.zen-hero__samplepills { display: flex; gap: var(--tomo-space-2); }
.zen-hero__samplepills span {
  padding: 3px 12px;
  border: 1px solid var(--tomo-border-light);
  border-radius: var(--tomo-radius-full);
  font-size: 12px;
  font-weight: 600;
  color: var(--tomo-text-secondary);
}

@media (max-width: 1023px) {
  .zen-hero { grid-template-columns: minmax(0, 1fr); gap: var(--tomo-space-8); width: min(100%, 640px); }
  .zen-hero__preview { width: min(100%, 420px); padding-right: var(--tomo-space-8); }
}

@media (max-width: 640px) {
  .zen-page--hero.tomo-face {
    align-items: flex-start;
    padding: var(--tomo-space-8) var(--tomo-space-4);
    background: radial-gradient(120% 40% at 100% 0%, var(--tomo-accent-subtle), transparent 70%), var(--tomo-canvas);
  }
  .zen-hero__title { font-size: 30px; }
  .zen-hero__lede { font-size: 15px; }
  .zen-hero__benefits { margin-top: var(--tomo-space-6); }
  .zen-hero__cta { align-self: stretch; margin-top: var(--tomo-space-6); }
  .zen-hero__connect { width: 100%; }
  .zen-hero__preview { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .zen-hero__spin { animation: none; border-right-color: currentColor; opacity: 0.6; }
}

.zen-page__title {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.zen-page__sub { margin: 2px 0 0; font-size: 14px; color: var(--tomo-text-muted); }

/* ---------- Filters: New brief, then one-at-a-time chips ---------- */

.zen-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--tomo-space-2);
  margin-bottom: var(--tomo-space-6);
}

.zen-filters__new { margin-right: var(--tomo-space-2); }

.zen-filters__chip {
  min-height: 32px;
  padding: 0 var(--tomo-space-3);
  border: 1px solid var(--tomo-border-light);
  border-radius: var(--tomo-radius-full);
  background: var(--tomo-surface);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--tomo-text-secondary);
  cursor: pointer;
  transition: background var(--tomo-duration-fast) var(--tomo-ease-out),
              border-color var(--tomo-duration-fast) var(--tomo-ease-out),
              color var(--tomo-duration-fast) var(--tomo-ease-out);
}

.zen-filters__chip:hover { border-color: var(--tomo-border-strong); color: var(--tomo-text-primary); }
.zen-filters__chip:focus-visible { outline: 2px solid var(--tomo-accent); outline-offset: 1px; }

.zen-filters__chip--on {
  border-color: var(--tomo-accent);
  background: var(--tomo-accent-subtle);
  color: var(--tomo-accent);
}

/* ---------- Groups ---------- */

.zen-page__groups { display: flex; flex-direction: column; gap: var(--tomo-space-8); }

.zen-group__head {
  margin: 0 0 var(--tomo-space-3);
  font-size: 14px;
  font-weight: 700;
  color: var(--tomo-text-primary);
}

/* The rows: the kit's list (tomo-face.css .tomo-crow-list), one column at every width. */
.zen-group__rows { margin: 0; }

/* ---------- A row's sub line and open body ---------- */

.zen-row__headline { color: var(--tomo-text-secondary); }

.zen-row__error { margin: 0; font-size: 13px; font-weight: 600; color: var(--tomo-danger-ink); }

.zen-row__reason { margin: 0; font-size: 13px; color: var(--tomo-text-secondary); }

/* Facts: flat hairline rows, no boxes, as the connection rows have them. */
.zen-row__facts { margin: 0; border-top: 1px solid var(--tomo-border-subtle); }

.zen-row__fact {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 2px 16px;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px solid var(--tomo-border-subtle);
  font-size: 13.5px;
}

.zen-row__fact dt { color: var(--tomo-text-muted); font-size: 13px; }
.zen-row__fact dd { margin: 0; min-width: 0; color: var(--tomo-text-primary); }

.zen-row__actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--tomo-space-2); }
.zen-row__actions .tomo-btn { min-height: 32px; padding: 0 var(--tomo-space-3); font-size: 13px; }

/* ---------- States ---------- */

.zen-page__failure { align-items: center; }
.zen-page__failtext { flex: 1; }

.zen-page__empty { display: flex; flex-direction: column; align-items: center; gap: var(--tomo-space-3); padding: var(--tomo-space-12) 0; text-align: center; }

.zen-page__emptymark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--tomo-radius-lg);
  background: var(--tomo-accent-subtle);
  color: var(--tomo-accent);
}
.zen-page__emptytitle { margin: 0; font-size: 15px; font-weight: 600; color: var(--tomo-text-secondary); }

.zen-page__signin { display: flex; flex-direction: column; align-items: flex-start; gap: var(--tomo-space-3); }
.zen-page__signin .zen-connect__title,
.zen-page__signin .zen-connect__lede { margin: 0; }

/* Loading: a row-shaped placeholder, the collapsed row's height. */
.zen-row--skeleton {
  display: flex;
  align-items: center;
  gap: var(--tomo-crow-gap);
  min-height: calc(var(--tomo-crow-tile) + 2 * var(--tomo-crow-pad-y));
  padding: var(--tomo-crow-pad-y) var(--tomo-crow-pad-x);
}

.zen-row__skellines { display: flex; flex: 1; flex-direction: column; gap: 8px; min-width: 0; }

.zen-page__skel {
  display: block;
  border-radius: var(--tomo-radius-sm);
  background: var(--tomo-border-light);
  animation: zen-page-pulse 1.4s ease-in-out infinite;
}

.zen-page__skel--head { width: 260px; max-width: 70%; height: 14px; margin-bottom: var(--tomo-space-3); }
.zen-page__skel--tile { flex: none; width: var(--tomo-crow-tile); height: var(--tomo-crow-tile); border-radius: var(--tomo-radius-md); }
.zen-page__skel--name { width: 40%; height: 12px; }
.zen-page__skel--line { width: 75%; height: 10px; }

@keyframes zen-page-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* ---------- A text link and an inline error, for the pages beside the brief list ---------- */
/* They were .zen-card__link and .zen-card__error until the page's cards became the kit's rows. */

.zen-link {
  padding: 0;
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 600;
  color: var(--tomo-accent);
  cursor: pointer;
}

.zen-link:hover { text-decoration: underline; }
.zen-link:focus-visible { outline: 2px solid var(--tomo-accent); outline-offset: 2px; }

.zen-error { margin: 0; font-size: 12px; color: var(--tomo-danger-ink); }

/* ---------- A brief's settings (TO-56): rows of label and value, then the actions ---------- */

.zen-settings__column, .zen-edit__column { max-width: 760px; }

.zen-settings__back {
  display: inline-flex;
  align-items: center;
  gap: var(--tomo-space-1);
  margin: 0 0 var(--tomo-space-3);
  padding: 2px 0;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--tomo-text-secondary);
  cursor: pointer;
}

.zen-settings__back:hover { color: var(--tomo-accent); }
.zen-settings__back:focus-visible { outline: 2px solid var(--tomo-accent); outline-offset: 2px; }

.zen-settings__title { font-size: 22px; margin-bottom: var(--tomo-space-4); }

.zen-settings__rows { margin: 0 0 var(--tomo-space-6); }

.zen-settings__row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: var(--tomo-space-4);
  padding: var(--tomo-space-3) 0;
  border-top: 1px solid var(--tomo-border-subtle);
  font-size: 14px;
}

.zen-settings__row:first-child { border-top: 0; }
.zen-settings__row dt { font-weight: 600; color: var(--tomo-text-muted); }
.zen-settings__row dd { margin: 0; display: flex; flex-direction: column; gap: 2px; color: var(--tomo-text-primary); }
.zen-settings__status--stopped { color: var(--tomo-warn-ink) !important; font-weight: 600; }

.zen-settings__acts { display: flex; flex-wrap: wrap; gap: var(--tomo-space-2); }
.zen-settings__delete { color: var(--tomo-danger-ink); }

.zen-settings__micro {
  max-width: 60ch;
  margin: var(--tomo-space-3) 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--tomo-text-muted);
}

.zen-settings__how { display: inline-block; margin-top: var(--tomo-space-6); font-size: 14px; }

/* One inline confirmation: where Delete was, no modal. */
.zen-confirm {
  padding: var(--tomo-space-3) var(--tomo-space-4);
  border: 1px solid var(--tomo-danger-line);
  border-radius: var(--tomo-radius-md);
  background: var(--tomo-danger-bg);
}

.zen-confirm__q { margin: 0; font-size: 14px; font-weight: 700; color: var(--tomo-danger-ink); }
.zen-confirm__d { margin: 2px 0 0; font-size: 13px; color: var(--tomo-text-secondary); }
.zen-confirm__problem { margin: var(--tomo-space-2) 0 0; font-size: 13px; color: var(--tomo-danger-ink); }
.zen-confirm__acts { display: flex; gap: var(--tomo-space-2); margin-top: var(--tomo-space-3); }

.zen-confirm .tomo-btn--danger {
  border: 0;
  background: var(--tomo-danger);
  color: var(--tomo-on-danger);
}

@media (max-width: 640px) {
  .zen-settings__row { grid-template-columns: 1fr; gap: 2px; }
}

/* ---------- How ZenAI works (E1, TO-57) ---------- */

.zen-how__title { margin-bottom: 2px; }
.zen-how__sub { margin-bottom: var(--tomo-space-6); }
.zen-how__section { margin-bottom: var(--tomo-space-6); }
.zen-how__head {
  margin: 0 0 var(--tomo-space-2);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--tomo-text-muted);
}

/* Every part is a collapsible kit row (Ro, 26 Oct 2026): one column, no card grids. */
.zen-how__rows > li { min-width: 0; }
.zen-how__num { font-size: 15px; font-weight: 700; line-height: 1; }

.zen-how__line { font-size: 13px; line-height: 1.45; color: var(--tomo-text-secondary); margin: 0; }

.zen-how__last {
  margin: 0 0 var(--tomo-space-2);
  padding: var(--tomo-space-3) var(--tomo-space-4);
  border-radius: var(--tomo-radius-md);
  background: var(--tomo-surface-sunken);
  border: 1px solid var(--tomo-border-light);
  font-size: 13px;
  color: var(--tomo-text-secondary);
}
.zen-how__last--stopped { border-color: var(--tomo-warn-line); color: var(--tomo-warn-ink); font-weight: 600; }
.zen-how__last .zen-link { margin-left: var(--tomo-space-2); }

/* ---------- Phone ---------- */

@media (max-width: 640px) {
  .zen-page__column, .zen-page__frame { padding-top: var(--tomo-space-4); }
  .zen-row__fact { grid-template-columns: 96px minmax(0, 1fr); }
  .zen-filters { gap: 6px; }
  .zen-filters__new { width: 100%; margin: 0 0 var(--tomo-space-1); }
}

@media (prefers-reduced-motion: reduce) {
  .zen-page__skel { animation: none; }
}

/* ---------- TO-58: Pinned and New on the collapsed row (the on-mock strip is the row's own) ---------- */

.zen-row__chip {
  display: inline-block;
  margin-right: 6px;
  padding: 0 7px;
  border-radius: var(--tomo-radius-full);
  background: var(--tomo-surface-sunken);
  color: var(--tomo-text-secondary);
  font-size: 11px;
  font-weight: 700;
  line-height: 16px;
  vertical-align: 1px;
}

.zen-row__chip--new { background: var(--tomo-accent); color: var(--tomo-surface); }
