/* ==================================================================
   OryxBrain portal. Light theme only.
   Colour, type, radius, shadow and motion come from brand/tokens.css
   (--ox-*), linked before this file. Nothing here defines a new colour.
   ================================================================== */

:root {
  /* Short names kept for the publish, approvals and sandbox styles; each one resolves to a brand token. */
  --navy: var(--ox-brand);
  --navy-hover: var(--ox-ink);
  --white: var(--ox-surface);
  --light-blue: var(--ox-brand-soft);
  --dark-grey: var(--ox-ink-2);
  --light-grey: var(--ox-ink-3);
  --muted: var(--ox-ink-3);
  --page: var(--ox-bg);
  --surface: var(--ox-surface);
  --surface-soft: var(--ox-bg);
  --surface-tint: var(--ox-surface-2);
  --line: var(--ox-line);
  --line-strong: var(--ox-line-2);
  --line-hover: var(--ox-line-2);
  --danger: var(--ox-danger-ink);
  --danger-bg: var(--ox-danger-soft);
  --danger-line: color-mix(in srgb, var(--ox-danger) 28%, var(--ox-surface));
  --ok: var(--ox-ok);
  --warn: var(--ox-warn);
  --radius: var(--ox-r-md);
  --radius-lg: var(--ox-r-lg);
  --radius-pill: var(--ox-r-full);
  --font: var(--ox-font);
  --mono: var(--ox-mono);
  --ease: var(--ox-ease);

  --topbar-h: 56px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  color-scheme: light;
}

body {
  min-height: 100dvh;
  margin: 0;
  background: var(--ox-bg);
  color: var(--ox-ink);
  font-family: var(--font);
  font-size: var(--ox-t-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body[data-screen="app"] {
  overflow: hidden;
}

::selection {
  background: var(--light-blue);
  color: var(--navy);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h2,
h3 {
  font-weight: var(--ox-heading-weight);
  letter-spacing: var(--ox-heading-tracking);
  color: var(--ox-ink);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

svg {
  flex: none;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 2px solid var(--ox-brand);
  outline-offset: 2px;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: var(--radius-pill);
  background: var(--line-strong);
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--line-hover);
  background-clip: padding-box;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: fixed;
  z-index: 200;
  top: 8px;
  left: 8px;
  padding: 8px 12px;
  border-radius: var(--ox-r-sm);
  background: var(--ox-brand);
  color: var(--white);
  font-size: var(--ox-t-sm);
  font-weight: 600;
  transform: translateY(-160%);
  transition: transform var(--ox-fast) var(--ox-ease);
}

.skip-link:focus {
  transform: translateY(0);
}

/* ------------------------------------------------------------------ */
/* Shared components: buttons, badges, skeletons                       */
/* ------------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--ox-r-sm);
  background: transparent;
  color: var(--ox-ink);
  font-size: var(--ox-t-sm);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  transition:
    background-color var(--ox-fast) var(--ox-ease),
    border-color var(--ox-fast) var(--ox-ease),
    box-shadow var(--ox-fast) var(--ox-ease),
    color var(--ox-fast) var(--ox-ease);
}

.btn-primary {
  background: var(--ox-brand);
  border-color: var(--ox-brand);
  color: var(--ox-surface);
}

.btn-primary:hover {
  background: var(--ox-ink);
  border-color: var(--ox-ink);
}

/* Secondary: white with a hairline and a resting shadow. */
.btn-ghost {
  background: var(--ox-surface);
  border-color: var(--ox-line-2);
  box-shadow: var(--ox-shadow-1);
  color: var(--ox-ink);
}

.btn-ghost:hover {
  background: var(--ox-surface-2);
}

/* Text only. */
.btn-quiet {
  color: var(--ox-ink-2);
}

.btn-quiet:hover {
  background: var(--ox-surface-2);
  color: var(--ox-ink);
}

.btn-small {
  height: 30px;
  padding: 0 10px;
}

.btn:disabled,
.btn.is-loading {
  opacity: 0.65;
  cursor: default;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--ox-r-sm);
  background: transparent;
  color: var(--ox-ink-2);
  transition:
    background-color var(--ox-fast) var(--ox-ease),
    color var(--ox-fast) var(--ox-ease);
}

.icon-button:hover {
  background: var(--ox-surface-2);
  color: var(--ox-ink);
}

/* Status badges: sentence case, one colour each. Live = ok, In review = warn, Sandbox = info, Not approved = danger. */
.badge,
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 9px;
  border: 0;
  border-radius: var(--ox-r-full);
  background: var(--ox-surface-2);
  color: var(--ox-ink-2);
  font-size: var(--ox-t-xs);
  font-weight: 600;
  white-space: nowrap;
}

.badge::before,
.status-dot {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-badge .status-dot {
  background: currentColor;
}

.badge-ok,
.status-badge.is-ok {
  background: var(--ox-ok-soft);
  color: var(--ox-ok-ink);
}

.badge-warn,
.status-badge.is-warn {
  background: var(--ox-warn-soft);
  color: var(--ox-warn-ink);
}

.badge-info {
  background: var(--ox-info-soft);
  color: var(--ox-info-ink);
}

.badge-danger {
  background: var(--ox-danger-soft);
  color: var(--ox-danger-ink);
}

/* Loading placeholder shown until data arrives. */
.skeleton {
  display: block;
  border-radius: var(--ox-r-sm);
  background: linear-gradient(90deg, var(--ox-surface-2) 25%, var(--ox-bg) 50%, var(--ox-surface-2) 75%);
  background-size: 200% 100%;
  animation: ox-shimmer 1.2s linear infinite;
}

@keyframes ox-shimmer {
  to {
    background-position: -200% 0;
  }
}

/* Tinted icon tiles, by category. */
.tile-ic {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: var(--ox-r-md);
  background: var(--ox-surface-2);
  color: var(--ox-ink-2);
}

.k-teal {
  background: var(--ox-accent-soft);
  color: var(--ox-accent);
}

.k-navy {
  background: var(--ox-brand-soft);
  color: var(--ox-brand);
}

.k-amber {
  background: var(--ox-warn-soft);
  color: var(--ox-warn-ink);
}

.k-blue {
  background: var(--ox-info-soft);
  color: var(--ox-info-ink);
}

/* ------------------------------------------------------------------ */
/* Boot                                                                */
/* ------------------------------------------------------------------ */

.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 6px;
  background: var(--page);
}

.boot-logo {
  height: 88px;
  width: auto;
  animation: boot-flash 1.4s ease-in-out infinite;
}

/* The loading screen is the logo alone. It fades out and in while the page loads. */
@keyframes boot-flash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

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

/* ------------------------------------------------------------------ */
/* Sign in                                                            */
/* ------------------------------------------------------------------ */

.login-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  background: var(--page);
}

.login-title {
  font-size: 21px;
  line-height: 1.25;
}

.login-subtitle {
  margin-top: -10px;
  font-size: 13.5px;
  color: var(--muted);
}

.form-alert {
  padding: 9px 11px;
  border: 1px solid var(--danger-line);
  border-radius: 6px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 13px;
}

.field {
  display: grid;
  align-content: start;
  gap: 6px;
}

.field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--dark-grey);
}

.field input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--navy);
  font-size: 14px;
  outline: none;
  transition:
    border-color 140ms var(--ease),
    box-shadow 140ms var(--ease);
}

.field input::placeholder {
  color: var(--muted);
}

.field input:focus {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px var(--ox-brand-soft);
}

.input-shell {
  position: relative;
}

.input-shell input {
  padding-right: 44px;
}

.field-action {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
}

.field-action:hover {
  color: var(--navy);
}

.btn-login {
  height: 42px;
  width: 100%;
  margin-top: 2px;
}

.demo-hint {
  padding: 12px 0 0;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 4px;
}

.demo-hint-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.demo-accounts {
  display: grid;
  gap: 6px;
}

.demo-account {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) auto;
  grid-template-areas: "role email use" "role password use";
  align-items: center;
  column-gap: 10px;
  row-gap: 2px;
}

.demo-account-role {
  grid-area: role;
  font-size: 13px;
  font-weight: 600;
  color: var(--dark-grey);
}

.demo-account code:nth-of-type(1) { grid-area: email; justify-self: start; }
.demo-account code:nth-of-type(2) { grid-area: password; justify-self: start; }
.demo-account-use { grid-area: use; }

.demo-hint code {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--dark-grey);
  background: var(--surface-tint);
  border-radius: 4px;
  padding: 1px 6px;
}

.login-help {
  font-size: 13px;
  color: var(--muted);
}

/* ------------------------------------------------------------------ */
/* Application shell                                                  */
/* ------------------------------------------------------------------ */

.app-shell {
  display: flex;
  min-height: 100dvh;
}

.app-frame {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

.app-body {
  flex: 1;
  min-height: 0;
  display: flex;
}

/* ------------------------------------------------------------------ */
/* Top bar: translucent white, 56px, hairline                          */
/* ------------------------------------------------------------------ */

.topbar {
  position: relative;
  z-index: 20;
  flex: none;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 28px;
  border-bottom: 1px solid var(--ox-line);
  background: rgba(255, 255, 255, 0.82);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.topbar-brand {
  flex: none;
  display: flex;
  align-items: center;
}

.topbar-logo {
  height: 26px;
  width: auto;
}

/* Icon-only brand mark, hidden by default: the crowded top bar shows it in place of the wordmark
   (see the phone rules in style.css and browser.css) so the brand stays visible. */
.topbar-mark {
  display: none;
  height: 26px;
  width: auto;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: none;
}

.topnav-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: var(--ox-r-sm);
  color: var(--ox-ink-2);
  font-size: var(--ox-t-sm);
  font-weight: 500;
  white-space: nowrap;
  transition:
    background-color var(--ox-fast) var(--ox-ease),
    color var(--ox-fast) var(--ox-ease);
}

.topnav-item:hover {
  background: var(--ox-surface-2);
  color: var(--ox-ink);
}

.topnav-item.is-active {
  background: var(--ox-brand-soft);
  color: var(--ox-brand);
}

/* ------------------------------------------------------------------ */
/* Search or jump to…                                                  */
/* ------------------------------------------------------------------ */

.search-wrap {
  position: relative;
  flex: 0 1 320px;
  margin-left: auto;
}

.search-wrap > .search-icon {
  position: absolute;
  top: 50%;
  left: 12px;
  transform: translateY(-50%);
  color: var(--ox-ink-3);
  pointer-events: none;
}

#global-search {
  width: 100%;
  height: 36px;
  padding: 0 56px 0 36px;
  border: 1px solid transparent;
  border-radius: var(--ox-r-md);
  background: var(--ox-surface-2);
  color: var(--ox-ink);
  font-size: var(--ox-t-sm);
  outline: none;
  transition:
    background-color var(--ox-fast) var(--ox-ease),
    border-color var(--ox-fast) var(--ox-ease);
}

#global-search::placeholder {
  color: var(--ox-ink-3);
}

#global-search::-webkit-search-cancel-button {
  display: none;
}

#global-search:focus {
  background: var(--ox-surface);
  border-color: var(--ox-line-2);
}

.search-key {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  padding: 1px 6px;
  border: 1px solid var(--ox-line-2);
  border-radius: var(--ox-r-sm);
  background: var(--ox-surface);
  color: var(--ox-ink-2);
  font-family: inherit;
  font-size: var(--ox-t-xs);
  font-weight: 600;
  pointer-events: none;
}

.search-results {
  position: absolute;
  z-index: 60;
  top: calc(100% + 6px);
  right: 0;
  width: max(100%, 420px);
  max-height: min(60vh, 520px);
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--ox-line);
  border-radius: var(--ox-r-md);
  background: var(--ox-surface);
  box-shadow: var(--ox-shadow-2);
}

.search-section-label {
  padding: 8px 10px 4px;
  font-size: var(--ox-t-xs);
  font-weight: 600;
  color: var(--ox-ink-3);
}

.search-result {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: var(--ox-r-sm);
  background: transparent;
  text-align: left;
}

.search-result.is-active,
.search-result:hover {
  background: var(--ox-surface-2);
}

.search-result-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: var(--ox-r-sm);
  background: var(--ox-brand-soft);
  color: var(--ox-brand);
}

.search-result-icon.has-face { padding: 0; overflow: hidden; background: var(--ox-brand-soft); }
.search-result-icon.has-face img { width: 100%; height: 100%; object-fit: cover; display: block; }
.search-result-icon.tone-teal {
  background: var(--ox-accent-soft);
  color: var(--ox-accent);
}

.search-result-icon.tone-amber {
  background: var(--ox-warn-soft);
  color: var(--ox-warn-ink);
}

.search-result-icon.tone-blue {
  background: var(--ox-info-soft);
  color: var(--ox-info-ink);
}

.search-result-copy {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.search-result-title {
  font-size: var(--ox-t-sm);
  font-weight: 600;
  color: var(--ox-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-meta {
  font-size: var(--ox-t-xs);
  color: var(--ox-ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-kind {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--ox-t-xs);
  color: var(--ox-ink-3);
}

.search-empty {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 22px 12px;
  text-align: center;
  font-size: var(--ox-t-sm);
  color: var(--ox-ink-3);
}

/* Reload and open-in-new-tab, shown while an app is on screen. */
.viewer-tools {
  flex: none;
  display: flex;
  align-items: center;
  gap: 2px;
}

.viewer-tools[hidden] {
  display: none;
}

/* ------------------------------------------------------------------ */
/* Avatar menu                                                         */
/* ------------------------------------------------------------------ */

.topbar-user {
  position: relative;
  display: flex;
  align-items: center;
}

.user-chip {
  display: flex;
  align-items: center;
  padding: 0;
  border: 0;
  border-radius: var(--ox-r-full);
  background: transparent;
  cursor: pointer;
}

.user-chip:hover .avatar,
.user-chip[aria-expanded="true"] .avatar {
  box-shadow: 0 0 0 3px var(--ox-brand-soft);
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--ox-r-full);
  background: var(--ox-brand);
  color: var(--ox-surface);
  font-size: var(--ox-t-xs);
  font-weight: 600;
  transition: box-shadow var(--ox-fast) var(--ox-ease);
}

.user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 60;
  min-width: 220px;
  padding: 6px;
  border: 1px solid var(--ox-line);
  border-radius: var(--ox-r-md);
  background: var(--ox-surface);
  box-shadow: var(--ox-shadow-2);
}

.user-menu[hidden] {
  display: none;
}

.user-menu-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px 10px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--ox-line);
}

.user-menu-head strong {
  font-size: var(--ox-t-sm);
  font-weight: 600;
  color: var(--ox-ink);
}

.user-menu-head span {
  font-size: var(--ox-t-xs);
  color: var(--ox-ink-3);
  overflow-wrap: anywhere;
}

.user-menu-head .user-menu-role:empty {
  display: none;
}

.user-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--ox-r-sm);
  background: transparent;
  color: var(--ox-ink);
  font: inherit;
  font-size: var(--ox-t-sm);
  text-decoration: none;
  cursor: pointer;
}

.user-menu-item:hover,
.user-menu-item:focus-visible {
  background: var(--ox-surface-2);
  outline: none;
}

.user-menu-item:disabled {
  opacity: 0.6;
  cursor: progress;
}

.user-menu-admin {
  margin-bottom: 2px;
}

/* ------------------------------------------------------------------ */
/* Wiki note tree                                                      */
/* ------------------------------------------------------------------ */

.note-panel {
  flex: none;
  width: 236px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--ox-line);
  background: var(--ox-surface);
}

.note-panel.is-empty {
  display: none;
}

.note-panel-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--ox-line);
}

.note-panel-title {
  font-size: var(--ox-t-xs);
  font-weight: 600;
  color: var(--ox-ink-3);
}

.note-panel-count {
  font-size: var(--ox-t-xs);
  color: var(--ox-ink-3);
}

.note-tree {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 8px 16px;
}

.note-folder-head {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 7px 10px;
  font-size: var(--ox-t-xs);
  font-weight: 600;
  letter-spacing: 0;
  color: var(--ox-ink-3);
}

.note-folder-count {
  margin-left: auto;
  font-weight: 500;
}

.note-folder-items {
  display: grid;
  padding: 2px 0 8px;
}

.note-link {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 10px 0 26px;
  border-radius: var(--ox-r-sm);
  font-size: var(--ox-t-sm);
  color: var(--ox-ink-2);
  transition:
    background-color var(--ox-fast) var(--ox-ease),
    color var(--ox-fast) var(--ox-ease);
}

.note-link:hover {
  background: var(--ox-surface-2);
  color: var(--ox-ink);
}

.note-link.is-active {
  background: var(--ox-brand-soft);
  color: var(--ox-brand);
  font-weight: 600;
}

.note-link-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: var(--ox-r-full);
}

.note-link-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ------------------------------------------------------------------ */
/* Main content and page headers                                       */
/* ------------------------------------------------------------------ */

.main-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 40px 64px 56px;
}

.page {
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 1180px;
  margin: 0 auto;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.page-head-copy {
  display: grid;
  gap: 4px;
}

.page-head h1 {
  font-size: var(--ox-t-xl);
  line-height: 1.2;
}

.page-lede {
  max-width: 62ch;
  font-size: var(--ox-t-base);
  color: var(--ox-ink-2);
}

.page-head-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ------------------------------------------------------------------ */
/* Home                                                               */
/* ------------------------------------------------------------------ */

.page-home {
  gap: 36px;
}

.home-eyebrow {
  margin-bottom: 6px;
  font-size: var(--ox-t-sm);
  font-weight: 500;
  color: var(--ox-ink-3);
}

.home-hero h1 {
  font-size: var(--ox-t-2xl);
  line-height: 1.15;
}

.ask {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 22px;
  padding: 10px 10px 10px 20px;
  border: 1px solid var(--ox-line);
  border-radius: var(--ox-r-lg);
  background: var(--ox-surface);
  box-shadow: var(--ox-shadow-2);
}

.ask:focus-within {
  border-color: var(--ox-line-2);
}

.ask-input {
  display: block;
  flex: 1;
  min-width: 0;
  min-height: 24px;
  max-height: 200px;
  padding: 0;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--ox-ink);
  font: inherit;
  font-size: var(--ox-t-md);
  line-height: 1.5;
}

.ask-input::placeholder {
  color: var(--ox-ink-3);
}

/* The mic sits beside the send button: a quiet round button, teal while it listens. */
.ask-mic {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ox-ink-2);
  cursor: pointer;
  transition: background-color var(--ox-fast) var(--ox-ease), color var(--ox-fast) var(--ox-ease);
}

.ask-mic:hover {
  background: var(--ox-surface-2);
  color: var(--ox-brand);
}

.ask-mic.is-on {
  background: var(--ox-brand-soft);
  color: var(--ox-accent);
}

.ask-send {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--ox-brand);
  color: var(--ox-surface);
  cursor: pointer;
  transition: background-color var(--ox-fast) var(--ox-ease);
}

.ask-send:hover {
  background: var(--ox-ink);
}

/* One card across the page: Company brain. */
.home-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: stretch;
  gap: 20px;
}

.home-split > section {
  display: flex;
  flex-direction: column;
  gap: 12px;   /* heading to content: the same on every Home section */
  min-width: 0;
}

.home-split > section > .card {
  flex: 1;
}

/* The pinned AI coworkers stand beside the globe, one under the other. No scroll: a person pins up to six. */
.home-coworkers .tile-grid {
  grid-template-columns: 1fr;
  align-content: start;
}

.home-all-link {
  justify-self: start;
  padding: 6px 2px;
  font-weight: 600;
  color: var(--ox-brand);
  text-decoration: none;
}

.home-all-link:hover { text-decoration: underline; }

/* The pin on the page with all AI coworkers: filled when the coworker is on Home. */
.tile-pin.is-on { color: var(--ox-brand); background: var(--ox-brand-soft); }
.tile-pin.is-on svg { fill: currentColor; }
.coworker-list { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

/* Home: every section has the same heading, the same space under it and the same space between tiles. */
.page-home .content-section { gap: 12px; }
.page-home .section-head { min-height: 24px; align-items: center; }
.page-home .section-head > * { margin: 0; }

/* The globe is round, so it gets a fixed height, and the topics stand beside it. */
.home-split .brain-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 132px;
  grid-template-areas: "head head" "summary summary" "canvas legend";
  column-gap: 18px;
}

.home-split .brain-head { grid-area: head; }
.home-split .brain-summary { grid-area: summary; }

.home-split .brain-canvas {
  grid-area: canvas;
  flex: none;
  height: 360px;
  margin-bottom: 0;
}

.home-split .graph-legend {
  grid-area: legend;
  flex-direction: column;
  flex-wrap: nowrap;
  justify-content: center;
  gap: 10px;
  padding-left: 14px;
  border-left: 1px solid var(--ox-line);
  font-size: var(--ox-t-xs);
}

.section-link {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  gap: 5px;
  font-size: var(--ox-t-sm);
  font-weight: 600;
  color: var(--ox-accent);
}

.section-link:hover {
  text-decoration: underline;
}

.card {
  border: 1px solid var(--ox-line);
  border-radius: var(--ox-r-lg);
  background: var(--ox-surface);
  box-shadow: var(--ox-shadow-1);
}

.recent {
  display: flex;
  flex-direction: column;
  padding: 6px;
}

.ri {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--ox-r-md);
  min-width: 0;
}

a.ri:hover {
  background: var(--ox-surface-2);
}

.ri-ic {
  width: 34px;
  height: 34px;
  border-radius: var(--ox-r-md);
}

.ri-tx {
  flex: 1;
  min-width: 0;
}

.ri-t {
  font-size: var(--ox-t-base);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ri-s {
  font-size: var(--ox-t-sm);
  color: var(--ox-ink-3);
}

.ri-when {
  flex: none;
  font-size: var(--ox-t-sm);
  color: var(--ox-ink-3);
}

/* Inline empty state inside a card. */
.empty-note {
  flex: 1;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  padding: 32px 24px;
  text-align: center;
  color: var(--ox-ink-3);
  font-size: var(--ox-t-sm);
}

.empty-note .tile-ic {
  color: var(--ox-ink-3);
}

/* ------------------------------------------------------------------ */
/* Company brain card and knowledge graph                              */
/* ------------------------------------------------------------------ */

.brain-card {
  display: flex;
  flex-direction: column;
  padding: 18px;
}

.brain-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.brain-head h3 {
  font-size: var(--ox-t-base);
}

.brain-summary {
  display: none;
  margin-top: 8px;
  font-size: var(--ox-t-sm);
  line-height: 1.5;
  color: var(--ox-ink-2);
}

.brain-canvas,
.knowledge-canvas {
  position: relative;
  flex: 1;
  min-height: 190px;
  margin: 8px 0 10px;
  border-radius: var(--ox-r-md);
  background:
    radial-gradient(circle at 50% 50%, var(--ox-accent-soft), transparent 62%),
    radial-gradient(circle, color-mix(in srgb, var(--ox-brand) 7%, transparent) 1px, transparent 1.2px) 0 0 / 14px 14px;
}

.graph-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: var(--ox-t-xs);
  color: var(--ox-ink-2);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: var(--ox-r-full);
}

.kg-root {
  position: relative;
}

.kg-canvas {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.kg-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 6px;
  padding: 24px;
  text-align: center;
}

.kg-empty-title {
  font-size: var(--ox-t-base);
  font-weight: 600;
  color: var(--ox-ink);
}

.kg-empty-copy {
  max-width: 34ch;
  font-size: var(--ox-t-sm);
  color: var(--ox-ink-3);
}

.kg-empty-action {
  margin-top: 8px;
}

/* ------------------------------------------------------------------ */
/* Sections, tiles and cards                                           */
/* ------------------------------------------------------------------ */

.content-section {
  display: grid;
  gap: 14px;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.section-head h2 {
  font-size: var(--ox-t-md);
}

.section-head p {
  margin-top: 2px;
  font-size: var(--ox-t-sm);
  color: var(--ox-ink-2);
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.tile {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--ox-line);
  border-radius: var(--ox-r-md);
  background: var(--ox-surface);
  box-shadow: var(--ox-shadow-1);
  transition:
    box-shadow var(--ox-base) var(--ox-ease),
    transform var(--ox-base) var(--ox-ease),
    border-color var(--ox-base) var(--ox-ease);
}

a.tile:hover,
.tile:has(.tile-main:hover) {
  border-color: var(--ox-line-2);
  box-shadow: var(--ox-shadow-2);
  transform: translateY(-1px);
}

.tile-tx {
  flex: 1;
  min-width: 0;
}

.tile-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.tile-name > span:first-child,
.tile-name > .tile-main {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile-desc {
  overflow: hidden;
  font-size: var(--ox-t-sm);
  color: var(--ox-ink-3);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The whole tile is the link; a secondary action sits above it. */
.tile-main::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.tile-action {
  position: relative;
  z-index: 1;
}

.tile-add {
  border-style: dashed;
  border-color: var(--ox-line-2);
  background: transparent;
  box-shadow: none;
  color: var(--ox-ink-2);
}

.tile-add:hover {
  background: var(--ox-surface);
}

.tile-face {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--ox-surface-2);
}

/* ------------------------------------------------------------------ */
/* Apps page                                                           */
/* ------------------------------------------------------------------ */

.page-apps {
  gap: 24px;
}

.apps-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-tabs {
  display: flex;
  padding: 3px;
  border-radius: var(--ox-r-md);
  background: var(--ox-surface-2);
}

.filter-tab {
  padding: 5px 12px;
  border: 0;
  border-radius: var(--ox-r-sm);
  background: transparent;
  color: var(--ox-ink-2);
  font-size: var(--ox-t-sm);
  font-weight: 500;
  cursor: pointer;
}

.filter-tab em {
  margin-left: 4px;
  font-style: normal;
  color: var(--ox-ink-3);
}

.filter-tab[aria-pressed="true"] {
  background: var(--ox-surface);
  color: var(--ox-ink);
  box-shadow: var(--ox-shadow-1);
}

.filter-shell {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  width: 260px;
  max-width: 100%;
  margin-left: auto;
  padding: 0 12px;
  border: 1px solid var(--ox-line-2);
  border-radius: var(--ox-r-md);
  background: var(--ox-surface);
  color: var(--ox-ink-3);
}

.filter-input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ox-ink);
  font-size: var(--ox-t-sm);
}

.filter-input::placeholder {
  color: var(--ox-ink-3);
}

.tbl-card {
  overflow: hidden;
}

.tbl-scroll {
  overflow-x: auto;
}

.tbl {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.tbl th {
  padding: 12px 16px;
  border-bottom: 1px solid var(--ox-line);
  font-size: var(--ox-t-xs);
  font-weight: 600;
  text-align: left;
  color: var(--ox-ink-3);
}

.tbl td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--ox-line);
  font-size: var(--ox-t-sm);
  color: var(--ox-ink-2);
  vertical-align: middle;
}

.tbl tbody tr:last-child td {
  border-bottom: 0;
}

.tbl tr.tbl-row:hover td {
  background: var(--ox-bg);
}

.tbl .tbl-group td {
  padding: 8px 16px;
  background: var(--ox-bg);
  font-size: var(--ox-t-xs);
  font-weight: 600;
  color: var(--ox-ink-3);
}

.tbl-app {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
}

.tbl-app .tile-ic {
  width: 34px;
  height: 34px;
}

.tbl-app b {
  display: block;
  font-size: var(--ox-t-base);
  font-weight: 600;
  color: var(--ox-ink);
}

.tbl-link:hover b {
  text-decoration: underline;
}

.tbl-app small {
  display: block;
  font-size: var(--ox-t-sm);
  color: var(--ox-ink-3);
}

.tbl-num {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.tbl-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.tbl-empty td {
  padding: 28px 16px;
  text-align: center;
  color: var(--ox-ink-3);
}

.tbl-skel td {
  padding: 16px;
}

.tbl-skel .skeleton {
  height: 34px;
}

/* ------------------------------------------------------------------ */
/* Administration index                                                */
/* ------------------------------------------------------------------ */

.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.admin-grid .tile-desc {
  white-space: normal;
}

/* Cards in a row have descriptions of different lengths: start every card at the top so the titles line up. */
.admin-grid .tile {
  align-items: flex-start;
}

/* ------------------------------------------------------------------ */
/* Publish wizard                                                       */
/* ------------------------------------------------------------------ */

.page-publish {
  max-width: 1180px;
  margin: 0 auto;
}

.card-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 18px;
  margin-bottom: 18px;
}

.wizard {
  display: block;
}

.wizard > .form-alert {
  margin-bottom: 16px;
}

.wizard-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
  padding-bottom: 14px;
  overflow-x: auto;
}

.wizard-step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px 0 0;
  white-space: nowrap;
}

.wizard-step + .wizard-step {
  padding-left: 14px;
  border-left: 1px solid var(--line);
}

.wizard-step-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.wizard-step.is-active .wizard-step-dot {
  background: var(--navy);
  border-color: var(--navy);
  color: var(--white);
}

.wizard-step.is-done .wizard-step-dot {
  background: var(--light-blue);
  border-color: var(--line-strong);
  color: var(--navy);
}

.wizard-step-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
}

.wizard-step.is-active .wizard-step-label {
  color: var(--navy);
  font-weight: 600;
}

.wizard-step.is-done .wizard-step-label {
  color: var(--navy);
}

.wizard-body h2 {
  margin: 0 0 8px;
  font-size: 19px;
  color: var(--navy);
}

.muted-note {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
}

.prompt-block {
  margin: 0;
  padding: 14px 14px 52px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.65;
  color: var(--navy);
  white-space: pre-wrap;
  word-break: break-word;
}

.wizard-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.wizard-fields .field input {
  height: 40px;
}

.review-list {
  margin: 0 0 14px;
  display: grid;
  gap: 0;
}

.review-row {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}

.review-row:last-child {
  border-bottom: 0;
}

.review-row dt {
  color: var(--muted);
  font-weight: 500;
}

.review-row dd {
  margin: 0;
  color: var(--navy);
  font-weight: 500;
}

.wizard-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  margin-top: 4px;
}

@media (max-width: 700px) {
  .review-row {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .hide-sm {
    display: none;
  }
}

/* ------------------------------------------------------------------ */
/* Embedded app viewer                                                */
/* ------------------------------------------------------------------ */

.main-content.viewer-mode {
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.viewer {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.viewer-frame {
  position: relative;
  flex: 1;
  min-height: 0;
  background: var(--ox-bg);
}

.app-iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--ox-surface);
}

.iframe-loading {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--ox-bg);
  font-size: var(--ox-t-sm);
  color: var(--ox-ink-2);
}

.iframe-loading.is-hidden {
  display: none;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--ox-line-2);
  border-top-color: var(--ox-brand);
  border-radius: var(--ox-r-full);
  animation: spin 800ms linear infinite;
}

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

/* ------------------------------------------------------------------ */
/* Empty, restricted and not-found states                              */
/* ------------------------------------------------------------------ */

.empty-state {
  display: grid;
  justify-items: center;
  gap: 10px;
  width: min(620px, 100%);
  margin: 24px auto;
  padding: 48px 24px;
  border: 1px solid var(--ox-line);
  border-radius: var(--ox-r-lg);
  background: var(--ox-surface);
  box-shadow: var(--ox-shadow-1);
  text-align: center;
}

.empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--ox-r-md);
  background: var(--ox-surface-2);
  color: var(--ox-ink-2);
}

.empty-state h1 {
  font-size: var(--ox-t-lg);
}

.empty-state p {
  max-width: 46ch;
  font-size: var(--ox-t-base);
  color: var(--ox-ink-2);
}

.empty-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 6px;
}

/* ------------------------------------------------------------------ */
/* Toast                                                              */
/* ------------------------------------------------------------------ */

.toast {
  position: fixed;
  z-index: 120;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 8px);
  padding: 10px 16px;
  border-radius: var(--ox-r-sm);
  background: var(--ox-brand);
  color: var(--ox-surface);
  font-size: var(--ox-t-sm);
  box-shadow: var(--ox-shadow-2);
  opacity: 0;
  transition:
    opacity var(--ox-base) var(--ox-ease),
    transform var(--ox-base) var(--ox-ease);
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ------------------------------------------------------------------ */
/* Responsive                                                         */
/* ------------------------------------------------------------------ */

@media (max-width: 1100px) {
  .main-content {
    padding: 32px 40px 48px;
  }
}

@media (max-width: 900px) {
  .topbar {
    gap: 12px;
    padding: 0 16px;
  }

  /* Icon-only tabs; the label stays as the tooltip and accessible name. */
  .topnav-item {
    padding: 8px 10px;
  }

  .topnav-label {
    display: none;
  }

  .note-panel {
    display: none;
  }

  .search-wrap {
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
  }

  .search-results {
    width: 100%;
  }

  .home-split {
    grid-template-columns: 1fr;
  }

  .home-coworkers .tile-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    max-height: none;
    overflow: visible;
  }

  .tbl-hide-md {
    display: none;
  }
}

/* At 200% zoom (about 720px wide) the Apps table needs its Open column: drop Access too. */
@media (max-width: 800px) {
  .tbl-hide-sm {
    display: none;
  }
}

/* Open and Open sandbox line up on the same right edge. */
.tbl-open {
  min-width: 96px;
  justify-content: center;
}

@media (max-width: 640px) {
  .filter-shell {
    width: 100%;
    margin-left: 0;
  }

  .filter-tabs {
    max-width: 100%;
    overflow-x: auto;
  }

  .tbl-hide-sm,
  .tbl-open {
    display: none;
  }

  .tbl th,
  .tbl td {
    padding: 12px 10px;
  }

  .tbl-app {
    min-width: 0;
  }

  /* Phones: each app is a two-column row (name | status over actions) so nothing scrolls sideways. */
  .tbl,
  .tbl tbody {
    display: block;
  }

  .tbl thead {
    display: none;
  }

  .tbl tr.tbl-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 10px;
    border-bottom: 1px solid var(--ox-line);
  }

  .tbl tbody tr.tbl-row:last-child {
    border-bottom: 0;
  }

  .tbl tr.tbl-row td,
  .tbl tr.tbl-row:hover td {
    border-bottom: 0;
    background: transparent;
  }

  .tbl tr.tbl-row:hover {
    background: var(--ox-bg);
  }

  .tbl tr.tbl-row td:first-child {
    grid-row: span 2;
  }

  .tbl tr.tbl-row td:nth-child(3),
  .tbl tr.tbl-row td:last-child {
    justify-self: end;
    padding-block: 4px;
  }

  .tbl tr.tbl-row td:last-child:has(.tbl-actions:empty) {
    display: none;
  }

  .tbl tr.tbl-group,
  .tbl tr.tbl-empty,
  .tbl tr.tbl-skel {
    display: block;
  }

  .tbl tr.tbl-group td,
  .tbl tr.tbl-empty td,
  .tbl tr.tbl-skel td {
    display: block;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ------------------------------------------------------------------ */
/* Import from GitHub, app settings and secrets                        */
/* ------------------------------------------------------------------ */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px 16px;
}

.field-hint {
  margin-top: 4px;
  font-size: var(--ox-t-xs);
  color: var(--muted);
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.github-form .form-alert,
.settings-body + .form-alert {
  margin-top: 12px;
}

.form-alert.is-ok {
  border-color: color-mix(in srgb, var(--ox-ok) 28%, var(--ox-surface));
  background: var(--ox-ok-soft);
  color: var(--ox-ok-ink);
}

.settings-advanced {
  margin-top: 12px;
}

.settings-body {
  display: grid;
  gap: 16px;
}

.settings-list {
  display: grid;
  margin-bottom: 14px;
  border-top: 1px solid var(--line);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.settings-row-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.settings-key {
  font-family: var(--mono);
  font-size: var(--ox-t-sm);
  color: var(--navy);
}

.settings-value {
  font-size: var(--ox-t-sm);
  color: var(--muted);
  overflow-wrap: anywhere;
}

.settings-row-actions {
  display: flex;
  flex: none;
  gap: 6px;
}

.settings-empty {
  padding: 10px 0;
}

a.user-menu-item {
  text-decoration: none;
}

.user-menu-admin {
  margin-bottom: 2px;
}
.env-list { display: grid; gap: 8px; }
.env-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) 110px auto; gap: 8px; align-items: center; }
.env-row.is-secret { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) 110px minmax(0, 1.2fr) auto; }
.env-row input, .env-row select { width: 100%; min-width: 0; }
.env-key { font-family: var(--mono); font-size: 13px; }
.btn-icon { padding: 0 9px; }
.github-form .btn-small { justify-self: start; }

/* Admin: review queue count and sample data */
.queue-count {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 7px; margin-left: 4px;
  border-radius: var(--radius-pill); background: var(--navy); color: var(--white); font-size: var(--ox-t-xs); vertical-align: 2px;
}
.sample-list { display: grid; gap: 6px; margin: 4px 0 14px; }
.sample-row { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 12px; font-size: var(--ox-t-sm); line-height: 1.5; color: var(--dark-grey); }
.sample-row strong { color: var(--navy); font-weight: 600; }
.btn-danger { background: var(--surface); color: var(--danger); border: 1px solid var(--danger-line); }
.btn-danger:hover:not(:disabled) { background: var(--danger-bg); }
.schedule-form { display: grid; gap: 14px; }
.schedule-form textarea { width: 100%; resize: vertical; }
.schedule-when { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.schedule-list { display: grid; gap: 10px; }
.schedule-card { border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 14px 16px; display: grid; gap: 6px; }
.schedule-card.is-paused { background: var(--surface-soft); }
.schedule-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--navy); }
.schedule-task { margin: 0; white-space: pre-wrap; color: var(--dark-grey); font-size: var(--ox-t-base); }
.schedule-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }

@media (max-width: 720px) {
  .schedule-when { grid-template-columns: 1fr; }
  .env-row, .env-row.is-secret { grid-template-columns: 1fr 1fr; }
  .env-row .env-value, .env-row .env-host { grid-column: 1 / -1; }
  .sample-row { grid-template-columns: 1fr; gap: 0; }
}

/* Text areas and dropdowns look like the other inputs */
.field textarea, .field select, .env-row select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--navy);
  font: 14px/1.5 var(--font);
  outline: none;
  transition: border-color 140ms var(--ease), box-shadow 140ms var(--ease);
}
.field textarea { padding: 10px 12px; min-height: 84px; }
.field select, .env-row select {
  height: 42px; padding: 0 36px 0 12px; appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23022a3a' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.field textarea::placeholder { color: var(--muted); }
.field textarea:focus, .field select:focus, .env-row select:focus { border-color: var(--navy); box-shadow: 0 0 0 3px var(--ox-brand-soft); }
.field select + select { margin-top: 0; }
.gh-step .wizard-fields { max-width: 560px; }

/* Developer section: GitHub import or a direct upload */
/* Publish an app: the other two ways in, each a card that opens. */
.publish-option > summary {
  display: flex;
  flex-direction: column;
  gap: 2px;
  cursor: pointer;
  list-style: none;
  padding-right: 28px;
  position: relative;
}
.publish-option > summary::-webkit-details-marker { display: none; }
.publish-option > summary::after {
  content: "";
  position: absolute;
  right: 4px;
  top: 8px;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--ox-ink-3);
  border-bottom: 2px solid var(--ox-ink-3);
  transform: rotate(45deg);
  transition: transform var(--ox-base) var(--ox-ease);
}
.publish-option[open] > summary::after { transform: rotate(-135deg); top: 12px; }
.publish-option[open] > summary { margin-bottom: 16px; }
.publish-option-title { font-size: var(--ox-t-base); font-weight: 600; color: var(--ox-brand); }
.publish-option .muted-note { margin: 0; }
.publish-option .card-panel { padding: 0; border: 0; box-shadow: none; background: transparent; }
.bring-steps { display: grid; gap: 22px; }
.bring-step { display: grid; gap: 8px; }
.bring-step h3 { font-size: var(--ox-t-sm); }
.bring-step .prompt-block { max-height: 220px; overflow: auto; }

.publish-developer .developer-choices {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.publish-developer .developer-choices .muted-note { margin: 0; }
/* The upload picker: the native button looks like any other browser widget, so dress it as the
   Oryx secondary button. The input itself stays native — focusable, keyboard- and label-linked,
   and the code reads fileInput.files as before. ::-webkit-file-upload-button needs its own rule:
   an unknown pseudo-element would make Firefox drop a shared selector list. */
.field input[type="file"] {
  height: auto;
  padding: 4px 6px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--ox-r-sm);
  background: var(--surface);
  color: var(--dark-grey);
  font: 13px/1.4 var(--font);
}
.field input[type="file"]::file-selector-button {
  box-sizing: border-box;
  height: 36px;
  margin: 0 10px 0 0;
  padding: 0 14px;
  border: 1px solid var(--ox-line-2);
  border-radius: var(--ox-r-sm);
  background: var(--ox-surface);
  box-shadow: var(--ox-shadow-1);
  color: var(--ox-ink);
  font: 600 var(--ox-t-sm)/1 var(--font);
  cursor: pointer;
}
.field input[type="file"]::-webkit-file-upload-button {
  box-sizing: border-box;
  height: 36px;
  margin: 0 10px 0 0;
  padding: 0 14px;
  border: 1px solid var(--ox-line-2);
  border-radius: var(--ox-r-sm);
  background: var(--ox-surface);
  box-shadow: var(--ox-shadow-1);
  color: var(--ox-ink);
  font: 600 var(--ox-t-sm)/1 var(--font);
  cursor: pointer;
}
.field input[type="file"]::file-selector-button:hover,
.field input[type="file"]::-webkit-file-upload-button:hover {
  background: var(--ox-surface-2);
}
/* The token is a text field masked by CSS, so browsers do not see a password to autofill. */
.field input.is-masked { -webkit-text-security: disc; }

/* ---- AI coworker page ---- */
.page-coworker { display: grid; gap: 18px; }
.cw-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 18px; align-items: center; padding: 6px 0 4px; }
.cw-head-face { width: 72px; height: 72px; border-radius: 50%; background: var(--light-blue); box-shadow: 0 0 0 4px var(--ox-surface), var(--ox-shadow-1); }
.cw-head-copy { display: grid; gap: 4px; min-width: 0; }
.cw-head-copy h1 { margin: 0; }
.cw-head-copy .page-lede { margin: 0; }
.cw-eyebrow { font-size: var(--ox-t-xs); font-weight: 600; color: var(--ox-ink-3); }
.cw-steps { margin: 6px 0 0; padding-left: 20px; display: grid; gap: 8px; color: var(--dark-grey); line-height: 1.5; }
.cw-steps strong { color: var(--navy); }
.cw-form { display: grid; gap: 14px; max-width: 720px; }
.cw-subhead { margin: 18px 0 8px; font-size: var(--ox-t-base); color: var(--ox-ink); }
.cw-danger { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.cw-confirm { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; color: var(--danger); font-size: var(--ox-t-base); }
.face-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 10px; max-width: 560px; }
.face-option { padding: 4px; border: 2px solid transparent; border-radius: 50%; background: none; cursor: pointer; display: grid; place-items: center; }
.face-option img { width: 56px; height: 56px; border-radius: 50%; background: var(--light-blue); }
.face-option:hover { border-color: var(--line-hover); }
.face-option.is-selected { border-color: var(--navy); }
.face-option:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }
.wizard-fields.wide { max-width: 720px; }
@media (max-width: 720px) {
  .cw-head { grid-template-columns: auto minmax(0, 1fr); }
  .cw-head .btn { grid-column: 1 / -1; justify-content: center; }
}

/* Publish: submission actions and the sandbox helper window */
.subs-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.subs-actions:empty { display: none; }

/* ------------------------------------------------------------------ */
/* Phones (max-width: 640px)                                          */
/* ------------------------------------------------------------------ */
@media (max-width: 640px) {
  :root {
    --tabbar-h: 56px;
  }

  /* Leave room at the bottom for the fixed tab bar and safe area. */
  .app-body {
    padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  }

  /* Top bar: logo on the left, search, bell and avatar on the right. */
  .topbar {
    position: sticky;
    top: 0;
    gap: 8px;
    padding: 0 12px;
    background: var(--ox-surface);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  .topbar-brand {
    min-height: 44px;
    margin-right: auto;
    padding: 0;
  }

  .topbar-logo,
  .topbar-mark {
    height: 24px;
  }

  /* Main navigation moves to a fixed bottom tab bar with icons and labels. */
  .topbar-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
    padding: 4px 8px env(safe-area-inset-bottom, 0px);
    border-top: 1px solid var(--ox-line);
    background: var(--ox-surface);
  }

  .topnav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 44px;
    min-height: 44px;
    padding: 4px 2px;
    border-radius: var(--ox-r-sm);
    background: transparent;
    color: var(--ox-ink-3);
    font-size: var(--ox-t-xs);
    font-weight: 500;
    line-height: 1.1;
  }

  .topnav-item:hover {
    background: transparent;
    color: var(--ox-ink);
  }

  .topnav-item.is-active {
    background: transparent;
    color: var(--ox-brand);
    font-weight: 600;
  }

  .topnav-icon {
    width: 18px;
    height: 18px;
  }

  .topnav-label {
    display: block;
  }

  /* Top bar controls: search, bell, logins, browser and avatar share the same size and centre alignment. */
  .topbar .icon-button,
  .user-chip {
    box-sizing: border-box;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    justify-content: center;
  }

  .search-key {
    display: none;
  }

  .search-wrap {
    flex: 0 0 40px;
    width: 40px;
    min-width: 40px;
    height: 40px;
    margin-left: 0;
  }

  .search-wrap > .search-icon {
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--ox-ink-2);
  }

  #global-search {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--ox-r-sm);
    background: transparent;
    color: transparent;
    caret-color: transparent;
    cursor: pointer;
  }

  #global-search:hover {
    background: var(--ox-surface-2);
  }

  #global-search::placeholder {
    color: transparent;
  }

  .search-wrap:focus-within {
    position: absolute;
    left: 12px;
    right: 12px;
    top: 8px;
    width: auto;
    height: 40px;
    z-index: 30;
    background: var(--ox-surface);
    border-radius: var(--ox-r-md);
  }

  .search-wrap:focus-within > .search-icon {
    left: 12px;
    transform: translateY(-50%);
    color: var(--ox-ink-3);
  }

  .search-wrap:focus-within #global-search {
    width: 100%;
    height: 40px;
    padding: 0 14px 0 36px;
    border-radius: var(--ox-r-md);
    background: var(--ox-surface);
    border-color: var(--ox-line-2);
    color: var(--ox-ink);
    caret-color: auto;
    cursor: text;
  }

  .search-wrap:focus-within #global-search::placeholder {
    color: var(--ox-ink-3);
  }

  .search-results {
    left: 0;
    right: 0;
    width: auto;
    max-height: min(55dvh, 420px);
  }

  .user-menu {
    right: 0;
    max-width: calc(100vw - 24px);
  }

  .viewer-tools {
    display: none;
  }

  /* Page spacing and type scale. */
  .main-content {
    padding: 20px 16px 28px;
    overflow-x: hidden;
  }

  .main-content.viewer-mode {
    padding: 0;
  }

  .page,
  .page-home,
  .page-apps {
    gap: 24px;
  }

  .home-eyebrow {
    margin-bottom: 4px;
    font-size: var(--ox-t-sm);
  }

  .home-hero h1 {
    font-size: 26px;
    line-height: 1.2;
  }

  .page-head {
    gap: 12px;
  }

  .page-head h1,
  .wl-head h1,
  .wsw-head h1,
  .pp-head h1 {
    font-size: var(--ox-t-lg);
    line-height: 1.2;
  }

  .section-head {
    align-items: baseline;
    gap: 8px 12px;
    flex-wrap: nowrap;
  }

  .section-head > div {
    flex: 1;
    min-width: 0;
  }

  .section-link {
    flex: none;
    align-self: baseline;
  }

  /* Ask box: single-line placeholder, clean textarea with no resize mark, 40px controls on one line. */
  .ask {
    align-items: center;
    gap: 6px;
    margin-top: 16px;
    padding: 6px 6px 6px 14px;
    border-radius: var(--ox-r-md);
  }

  .ask-input {
    appearance: none;
    -webkit-appearance: none;
    height: 24px;
    min-height: 24px;
    font-size: var(--ox-t-base);
    line-height: 24px;
    overflow-x: hidden;
  }

  .ask-input::placeholder {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .ask-input::-webkit-resizer,
  .ask-input::-webkit-scrollbar {
    display: none;
  }

  .ask-mic,
  .ask-send {
    width: 40px;
    height: 40px;
  }

  /* Cards and grids. */
  .card,
  .card-panel,
  .wl-card,
  .pp-card,
  .apr-fact {
    border-radius: var(--ox-r-md);
  }

  .card-panel,
  .brain-card {
    padding: 14px 16px;
  }

  .recent {
    padding: 6px;
  }

  .ri {
    padding: 10px;
  }

  .empty-note {
    padding: 20px 16px;
  }

  .tile-grid,
  .admin-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .tile {
    padding: 14px 16px;
    border-radius: var(--ox-r-md);
  }

  /* Knowledge graph: cap height on phones, and show a compact summary line when fewer than 5 notes exist. */
  .brain-card,
  .home-split .brain-card {
    display: flex;
    max-height: none;
  }

  .brain-canvas,
  .knowledge-canvas,
  .home-split .brain-canvas {
    flex: none;
    height: 270px;
    min-height: 0;
    margin: 6px 0 12px;
  }

  /* Topics under the globe: two even columns, every one in view. */
  .graph-legend,
  .home-split .graph-legend {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 12px;
    padding-left: 0;
    border-left: 0;
    font-size: var(--ox-t-xs);
  }

  .brain-card.is-sparse {
    max-height: none;
    gap: 8px;
  }

  .brain-card.is-sparse .brain-canvas {
    display: none;
  }

  .brain-card.is-sparse .brain-summary {
    display: block;
    margin: 0;
  }

  /* Touch targets and publish steps. */
  .btn,
  .btn-small,
  .filter-tab {
    min-height: 44px;
  }

  .btn,
  .btn-small {
    height: auto;
  }

  .field-action,
  .vlt-head .icon-button {
    width: 44px;
    height: 44px;
  }

  .wizard-step:not(.is-active) .wizard-step-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .wizard-step {
    padding-right: 10px;
  }

  .wizard-step + .wizard-step {
    padding-left: 10px;
  }

  .toast {
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 12px);
    max-width: calc(100vw - 32px);
  }
}

/* Chat and Wiki viewers */
.viewer-tools-embedded .icon-button {
  flex-shrink: 0;
}

.app-shell:has(.viewer-tools-embedded:not([hidden])) :is(.viewer-frame, .iframe-loading) {
  background: var(--ox-surface);
}

.wiki-tree-tools,
.wiki-tree-backdrop {
  display: none;
}

@media (max-width: 900px) {
  .has-note-panel .app-body {
    position: relative;
  }

  .wiki-tree-tools {
    display: flex;
    flex: none;
    align-items: center;
    height: 48px;
    padding-inline: 8px;
    background: var(--ox-surface);
  }

  .wiki-tree-toggle {
    min-height: 44px;
  }

  .wiki-tree-toggle[aria-expanded="true"] {
    background: var(--ox-brand-soft);
  }

  .wiki-tree-backdrop {
    display: block;
    position: absolute;
    inset: 0;
    z-index: 3;
    background: var(--ox-line-2);
  }

  .note-panel-open .note-panel {
    display: flex;
    position: absolute;
    z-index: 4;
    inset: 48px auto var(--viewer-tab-space, 0px) 0;
    width: min(18rem, 85vw);
    box-shadow: var(--ox-shadow-2);
  }

  .note-panel-open .note-link {
    min-height: 44px;
  }
}

@media (max-width: 640px) {
  .app-shell:has(.viewer-tools-embedded:not([hidden])) {
    --viewer-tab-space: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  }

  .app-shell:has(.viewer-tools-embedded:not([hidden])) .app-frame {
    position: fixed;
    inset: var(--viewer-top, 0px) 0 auto;
    height: var(--viewer-height, 100dvh);
  }

  .app-shell:has(.viewer-tools-embedded:not([hidden])) .topbar-nav {
    position: absolute;
    top: calc(var(--viewer-height, 100dvh) - var(--viewer-tab-space));
    bottom: auto;
  }

  .topbar:has(.viewer-tools-embedded:not([hidden])) {
    gap: 3px;
    padding-inline: max(8px, env(safe-area-inset-left, 0px)) max(8px, env(safe-area-inset-right, 0px));
  }

  .topbar .viewer-tools-embedded:not([hidden]) {
    display: flex;
  }

  .topbar .viewer-tools-embedded button[aria-label="Reload"] {
    display: none;
  }

  .topbar:has(.viewer-tools-embedded:not([hidden])) :is(.icon-button, .user-chip, #global-search, .search-wrap) {
    min-width: 44px;
    min-height: 44px;
  }
}

@media (max-width: 390px) {
  .topbar:has(.viewer-tools-embedded:not([hidden])):has(.vault-button, .browser-button) {
    gap: 2px;
    padding-inline: max(4px, env(safe-area-inset-left, 0px)) max(4px, env(safe-area-inset-right, 0px));
  }

  .topbar:has(.viewer-tools-embedded:not([hidden])):has(.vault-button, .browser-button) .topbar-logo {
    display: none;
  }

  .topbar:has(.viewer-tools-embedded:not([hidden])):has(.vault-button, .browser-button) .topbar-mark {
    display: block;
  }
}

/* The prompt box with its copy button (Publish an app). */
.prompt-wrap { position: relative; border: 1px solid var(--ox-line-2); border-radius: var(--ox-r-md); background: var(--ox-surface-2); }
.prompt-tools { position: absolute; right: 10px; bottom: 10px; }
.prompt-tools .btn { background: var(--ox-surface); }
