/* Wheatley's screens.
 *
 * plinth.css carries the components and the tokens (--background, --foreground, --card,
 * --border, --muted-foreground, …, as RGB channels). This file is Wheatley's layout and
 * material, and only that: every class is `wh-` prefixed, nothing here sets a :root token,
 * so inside entropic or Cloud's portal the host's palette applies unchanged. The standalone
 * app sets the estate's ground in clients/web/style/ground.css.
 *
 * House style, the estate's (the website, Cloud's portal): monochrome, status carried by a
 * word, Geist and Geist Mono, one expo-out curve, nothing moving under reduced motion.
 */

.wh-app {
  --wh-rule: rgb(var(--border));
  --wh-surface: rgb(var(--card));
  --wh-raised: rgb(var(--secondary));
  --wh-ink: rgb(var(--foreground));
  --wh-muted: rgb(var(--muted-foreground));
  --wh-ease: cubic-bezier(0.16, 1, 0.3, 1);
  --wh-fast: 140ms;
  --wh-bar-h: 3.25rem;
  --wh-side-w: 17rem;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  color: var(--wh-ink);
  font-family: var(--font-sans);
}
.wh-app--embedded { min-height: 0; height: 100%; }

.wh-boot {
  display: flex; align-items: center; gap: 0.75rem; justify-content: center;
  min-height: 50vh; color: var(--wh-muted);
}
.wh-problem { margin: 1rem; }

/* --- The bar ------------------------------------------------------------ */

.wh-bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 0.75rem;
  height: var(--wh-bar-h); padding: 0 1rem;
  border-bottom: 1px solid var(--wh-rule);
  background: rgb(var(--background) / 0.86);
  backdrop-filter: blur(10px);
}
.wh-bar__brand {
  display: inline-flex; align-items: center; gap: 0.5rem;
  color: inherit; text-decoration: none;
  font-family: var(--font-mono); font-size: 0.95rem; letter-spacing: 0.02em;
}
.wh-bar__spacer { flex: 1; }
.wh-bar__link {
  color: var(--wh-muted); text-decoration: none;
  font-family: var(--font-mono); font-size: 0.8rem; text-transform: lowercase; letter-spacing: 0.04em;
}
.wh-bar__link:hover, .wh-bar__link[aria-current="page"] { color: var(--wh-ink); }
.wh-bar__menu {
  display: none; border: 0; background: none; color: inherit; font-size: 1.1rem;
  width: 2.25rem; height: 2.25rem; border-radius: var(--radius); cursor: pointer;
}
.wh-mark { display: inline-flex; width: 1.5rem; height: 1rem; }
.wh-mark svg { width: 100%; height: 100%; }

/* --- Body: list beside the conversation --------------------------------- */

.wh-body {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: var(--wh-side-w) minmax(0, 1fr);
}
.wh-app--embedded .wh-body { min-height: 100%; }
.wh-side {
  border-right: 1px solid var(--wh-rule);
  overflow-y: auto;
  max-height: calc(100dvh - var(--wh-bar-h));
  position: sticky; top: var(--wh-bar-h);
}
.wh-app--embedded .wh-side { max-height: none; position: static; }
.wh-main { min-width: 0; display: flex; flex-direction: column; }
.wh-main:focus { outline: none; }

@media (max-width: 760px) {
  .wh-bar__menu { display: inline-flex; align-items: center; justify-content: center; }
  .wh-body { grid-template-columns: minmax(0, 1fr); }
  .wh-side {
    position: fixed; z-index: 30; top: var(--wh-bar-h); bottom: 0; left: 0;
    width: min(20rem, 85vw); max-height: none;
    background: rgb(var(--background));
    transform: translateX(-102%);
    transition: transform 240ms var(--wh-ease);
    box-shadow: 0 18px 48px -12px rgb(0 0 0 / 0.3);
  }
  .wh-side--open { transform: none; }
  .wh-app--embedded .wh-side { position: static; transform: none; width: auto; box-shadow: none; border-right: 0; border-bottom: 1px solid var(--wh-rule); }
}

/* --- The conversation list ---------------------------------------------- */

.wh-list { display: flex; flex-direction: column; gap: 0.5rem; padding: 0.75rem; }
.wh-list__new {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.55rem 0.75rem; border: 1px solid var(--wh-rule); border-radius: var(--radius);
  color: inherit; text-decoration: none; font-weight: 500;
  background: var(--wh-surface);
}
.wh-list__new:hover { border-color: var(--wh-muted); }
.wh-list__account { padding: 0.25rem 0.25rem 0; }
.wh-list__items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.wh-list__link {
  display: block; padding: 0.45rem 0.6rem; border-radius: calc(var(--radius) - 2px);
  color: var(--wh-muted); text-decoration: none; font-size: 0.9rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wh-list__link:hover { background: var(--wh-raised); color: var(--wh-ink); }
.wh-list__item--active .wh-list__link { background: var(--wh-raised); color: var(--wh-ink); font-weight: 500; }
.wh-list__groups { display: flex; flex-direction: column; gap: 0.5rem; }
.wh-list__folder { margin: 0.5rem 0.25rem 0.1rem; color: var(--wh-muted); font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.wh-list__empty { margin: 0.5rem 0.25rem; color: var(--wh-muted); font-size: 0.85rem; }

/* --- A conversation ------------------------------------------------------ */

.wh-convo { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.wh-convo__head {
  display: flex; align-items: center; gap: 0.25rem;
  max-width: 48rem; width: 100%; margin: 0 auto; padding: 0.75rem 1rem 0; box-sizing: border-box;
}
.wh-convo__title {
  flex: 1; margin: 0; font-size: 1rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.wh-pane { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.wh-pane__scroll { flex: 1; overflow-y: auto; min-height: 12rem; }
.wh-transcript {
  max-width: 48rem; margin: 0 auto; padding: 1.25rem 1rem 2rem;
  display: flex; flex-direction: column; gap: 1.25rem;
}
.wh-transcript__skeleton { display: flex; flex-direction: column; gap: 0.75rem; }

.wh-hello { padding: 12vh 0 1rem; text-align: center; }
.wh-hello__title { margin: 0 0 1.5rem; font-size: clamp(1.4rem, 3vw, 1.9rem); font-weight: 600; letter-spacing: -0.01em; }
.wh-hello__ideas {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0.5rem;
}
.wh-idea {
  width: 100%; height: 100%; text-align: left; cursor: pointer;
  padding: 0.75rem 0.9rem; border-radius: var(--radius);
  border: 1px solid var(--wh-rule); background: var(--wh-surface); color: inherit; font: inherit; font-size: 0.9rem;
  transition: border-color var(--wh-fast) var(--wh-ease);
}
.wh-idea:hover { border-color: var(--wh-muted); }

.wh-turn { display: flex; flex-direction: column; gap: 0.5rem; line-height: 1.6; }
.wh-turn--user { align-items: flex-end; }
.wh-turn--user .wh-turn__text {
  margin: 0; max-width: 85%; white-space: pre-wrap; overflow-wrap: anywhere;
  padding: 0.6rem 0.9rem; border-radius: 1rem 1rem 0.25rem 1rem;
  background: var(--wh-raised);
}
.wh-turn__stats, .wh-turn__wait {
  margin: 0; color: var(--wh-muted); font-family: var(--font-mono); font-size: 0.75rem;
  display: flex; align-items: center; gap: 0.5rem;
}

.wh-think { border-left: 2px solid var(--wh-rule); padding: 0 0 0 0.75rem; color: var(--wh-muted); }
.wh-think > summary {
  cursor: pointer; font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 0.03em;
  list-style-position: inside;
}
.wh-think__body {
  margin: 0.4rem 0 0; white-space: pre-wrap; overflow-wrap: anywhere;
  font-family: var(--font-sans); font-size: 0.85rem; max-height: 18rem; overflow-y: auto;
}

/* --- Answers ------------------------------------------------------------- */

.wh-md { overflow-wrap: anywhere; }
.wh-md > :first-child { margin-top: 0; }
.wh-md > :last-child { margin-bottom: 0; }
.wh-md p, .wh-md ul, .wh-md ol, .wh-md blockquote { margin: 0 0 0.75rem; }
.wh-md ul, .wh-md ol { padding-left: 1.25rem; }
.wh-md blockquote { border-left: 2px solid var(--wh-rule); padding-left: 0.75rem; color: var(--wh-muted); }
.wh-md__h { margin: 1rem 0 0.5rem; font-size: 1rem; font-weight: 600; }
.wh-md__code {
  font-family: var(--font-mono); font-size: 0.85em;
  padding: 0.1em 0.35em; border-radius: 0.3rem; background: var(--wh-raised);
}
.wh-md__link { color: inherit; text-decoration: underline; text-underline-offset: 0.15em; }
.wh-md__pre {
  margin: 0 0 0.75rem; border: 1px solid var(--wh-rule); border-radius: var(--radius);
  background: var(--wh-surface); overflow: hidden;
}
.wh-md__lang {
  padding: 0.3rem 0.75rem; border-bottom: 1px solid var(--wh-rule);
  font-family: var(--font-mono); font-size: 0.7rem; color: var(--wh-muted); text-transform: lowercase;
}
.wh-md__pre pre { margin: 0; padding: 0.75rem; overflow-x: auto; font-family: var(--font-mono); font-size: 0.82rem; line-height: 1.5; }

/* --- The composer -------------------------------------------------------- */

.wh-composer {
  position: sticky; bottom: 0;
  padding: 0.5rem 1rem 1rem;
  background: linear-gradient(to top, rgb(var(--background)) 70%, rgb(var(--background) / 0));
}
.wh-composer__off { max-width: 48rem; margin: 0 auto 0.5rem; color: var(--wh-muted); font-size: 0.85rem; }
.wh-composer__box {
  max-width: 48rem; margin: 0 auto;
  border: 1px solid var(--wh-rule); border-radius: 1rem; background: var(--wh-surface);
  padding: 0.6rem 0.6rem 0.5rem 0.9rem;
  transition: border-color var(--wh-fast) var(--wh-ease);
}
.wh-composer__box:focus-within { border-color: var(--wh-muted); }
.wh-composer__input {
  display: block; width: 100%; box-sizing: border-box; resize: none;
  border: 0; outline: 0; background: none; color: inherit; font: inherit; line-height: 1.5;
  field-sizing: content; min-height: 1.5em; max-height: 14rem;
}
.wh-composer__row { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.4rem; }
.wh-composer__usage { flex: 1; color: var(--wh-muted); font-family: var(--font-mono); font-size: 0.7rem; }

.wh-toggle {
  display: inline-flex; align-items: center; gap: 0.4rem; cursor: pointer;
  padding: 0.25rem 0.6rem; border-radius: 999px;
  border: 1px solid var(--wh-rule); background: none; color: var(--wh-muted);
  font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.03em; text-transform: lowercase;
}
.wh-toggle__dot { width: 0.45rem; height: 0.45rem; border-radius: 50%; border: 1px solid currentColor; }
.wh-toggle[aria-pressed="true"] { color: var(--wh-ink); border-color: var(--wh-ink); }
.wh-toggle[aria-pressed="true"] .wh-toggle__dot { background: currentColor; }

/* --- Account chip and the avatar menu ------------------------------------ */

.wh-chip {
  display: inline-flex; align-items: center; gap: 0.35rem; max-width: 100%;
  padding: 0.1rem 0.5rem; border: 1px solid var(--wh-rule); border-radius: 999px;
  font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wh-chip__mark { font-size: 0.7rem; }
.wh-chip__role { color: var(--wh-muted); }
.wh-chip__role::before { content: "· "; }

.wh-avatar { position: relative; }
.wh-avatar__button {
  display: inline-flex; align-items: center; gap: 0.5rem; cursor: pointer;
  padding: 0.2rem 0.6rem 0.2rem 0.2rem; border-radius: 999px;
  border: 1px solid var(--wh-rule); background: var(--wh-surface); color: inherit; font: inherit;
}
.wh-avatar__initials, .wh-avatar__big {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.9rem; height: 1.9rem; border-radius: 50%;
  background: var(--wh-ink); color: rgb(var(--background));
  font-size: 0.75rem; font-weight: 600;
}
.wh-avatar__big { width: 2.5rem; height: 2.5rem; font-size: 0.9rem; flex: none; }
.wh-avatar__account { font-family: var(--font-mono); font-size: 0.75rem; max-width: 10rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wh-avatar__scrim { position: fixed; inset: 0; z-index: 40; }
.wh-avatar__menu {
  position: absolute; right: 0; top: calc(100% + 0.5rem); z-index: 41;
  width: min(22rem, calc(100vw - 2rem)); max-height: min(70vh, 34rem); overflow-y: auto;
  padding: 0.75rem; border: 1px solid var(--wh-rule); border-radius: calc(var(--radius) + 4px);
  background: rgb(var(--popover)); color: rgb(var(--popover-foreground));
  box-shadow: 0 18px 48px -12px rgb(0 0 0 / 0.3), 0 4px 12px -4px rgb(0 0 0 / 0.12);
}
.wh-avatar__who { display: flex; gap: 0.75rem; align-items: flex-start; padding-bottom: 0.75rem; border-bottom: 1px solid var(--wh-rule); }
.wh-avatar__name { margin: 0; font-weight: 600; }
.wh-avatar__email { margin: 0 0 0.4rem; color: var(--wh-muted); font-size: 0.85rem; overflow-wrap: anywhere; }
.wh-avatar__usage { margin: 0.4rem 0 0; color: var(--wh-muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.wh-settings__upgrade { margin: 0.25rem 0 0; font-size: 0.85rem; }
.wh-avatar__label {
  margin: 0.75rem 0 0.35rem; color: var(--wh-muted);
  font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.06em; text-transform: lowercase;
}
.wh-avatar__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.wh-avatar__other { display: flex; flex-direction: column; gap: 2px; padding: 0.25rem 0; }
.wh-avatar__ident { font-size: 0.85rem; padding: 0 0.5rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wh-avatar__item, .wh-avatar__action {
  display: flex; align-items: center; gap: 0.5rem; width: 100%; text-align: left; cursor: pointer;
  padding: 0.45rem 0.5rem; border: 0; border-radius: calc(var(--radius) - 2px);
  background: none; color: inherit; font: inherit; font-size: 0.88rem;
}
.wh-avatar__item:hover, .wh-avatar__action:hover { background: var(--wh-raised); }
.wh-avatar__stale { color: var(--wh-muted); font-size: 0.78rem; }
.wh-avatar__actions { margin-top: 0.75rem; padding-top: 0.5rem; border-top: 1px solid var(--wh-rule); }
.wh-avatar__action--danger { color: rgb(var(--destructive)); }

/* --- Settings and sign-in ------------------------------------------------ */

.wh-settings {
  max-width: 44rem; width: 100%; margin: 0 auto; padding: 1.5rem 1rem 3rem; box-sizing: border-box;
  display: flex; flex-direction: column; gap: 1.25rem;
}
.wh-settings__title { margin: 0; font-size: 1.4rem; font-weight: 600; }

.wh-signin { flex: 1; display: grid; place-items: center; padding: 2rem 1rem; }
.wh-signin__card {
  width: min(24rem, 100%); box-sizing: border-box; display: flex; flex-direction: column; gap: 1rem; align-items: flex-start;
  padding: 2rem; border: 1px solid var(--wh-rule); border-radius: calc(var(--radius) + 6px); background: var(--wh-surface);
}
.wh-signin__card .wh-mark { width: 3rem; height: 2rem; }
.wh-signin__title { margin: 0; font-family: var(--font-mono); font-size: 1.5rem; font-weight: 500; }
.wh-signin__lede { margin: 0; color: var(--wh-muted); }

/* --- entropic Home widget ------------------------------------------------ */

.wh-widget__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.wh-widget__list a { color: inherit; text-decoration: none; font-size: 0.9rem; }
.wh-widget__list a:hover { text-decoration: underline; }
.wh-widget__empty { margin: 0; color: rgb(var(--muted-foreground)); font-size: 0.85rem; }
.wh-widget__chip { font-family: var(--font-mono); font-size: 0.72rem; color: rgb(var(--muted-foreground)); }

/* --- Motion and focus ----------------------------------------------------- */

.wh-app :focus-visible { outline: 2px solid rgb(var(--focus-ring)); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  .wh-app *, .wh-app *::before, .wh-app *::after { transition: none !important; animation: none !important; }
}
:root[data-motion="reduced"] .wh-app * { transition: none !important; animation: none !important; }

.wh-people { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.wh-people__row { display: flex; flex-direction: column; }
.wh-people__name { font-weight: 500; }
.wh-people__email { color: var(--wh-muted); font-size: 0.85rem; }
.wh-runs__row { display: flex; align-items: center; gap: 0.5rem; justify-content: flex-end; flex-wrap: wrap; }
.wh-runs__slots, .wh-runs__meta, .wh-runs__empty { color: var(--wh-muted); font-size: 0.85rem; margin: 0; margin-right: auto; }
.wh-runs__back { color: var(--wh-muted); font-size: 0.85rem; }
.wh-runs__task p { white-space: pre-wrap; }
.wh-runs__log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.wh-runs__event { border-left: 2px solid var(--wh-muted); padding-left: 0.6rem; }
.wh-runs__event--error { border-color: var(--wh-ink); }
.wh-runs__kind { color: var(--wh-muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; }
.wh-runs__body { margin: 0.2rem 0 0; white-space: pre-wrap; word-break: break-word; font: inherit; }
