/* Glampfire app pages (everything signed in except the chat): content sits on the
   app window in white rounded cards, with the page title in the header. */
body.app:not(.sidebar, .card-page) {
  .app-card { display: none; }

  #nav {
    border: 0;
    min-block-size: 56px;
    padding: 4px 28px 6px;

    /* White circular icon buttons */
    .btn:not(dialog *):not(.nav-button) {
      --btn-background: var(--gf-surface);
      --btn-border-color: transparent;
      --btn-size: 40px;

      border-radius: 999px;
      box-shadow: var(--gf-shadow-card);

      &:hover { --btn-background: var(--gf-hover); }
    }
  }

  #main-content { overflow-y: auto; }

  /* The title lines up with the content column below it. */
  #nav {
    inline-size: 100%;
    justify-self: center;
    max-inline-size: calc(760px + 56px);
  }

  &:has(.page--wide) #nav { max-inline-size: calc(1080px + 56px); }
}

#nav .flex-item-justify-start { order: -1; }
#nav .flex-item-justify-end { margin-inline-start: auto; order: 1; }

.page-title {
  flex: 1;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.02em;
  margin: 0;
  min-inline-size: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-subtitle {
  color: var(--gf-ink-subtle);
  display: block;
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0;
}

/* Page column */
.page {
  display: grid;
  gap: 16px;
  inline-size: 100%;
  margin-inline: auto;
  max-inline-size: 760px;
  padding: 8px 28px 64px;

  @media (max-width: 100ch) { padding: 4px 14px 40px; }
}

.page--wide { max-inline-size: 1080px; }

/* Cards: radius 24 = 16 inner + 8 gap; inner groups use 16 */
.card {
  background-color: var(--gf-surface);
  border-radius: 24px;
  box-shadow: var(--gf-shadow-card);
  min-inline-size: 0;
  padding: 24px;

  @media (max-width: 100ch) { padding: 18px; border-radius: 20px; }
}

.card--danger {
  box-shadow: var(--gf-shadow-card), inset 0 0 0 1px color-mix(in oklch, var(--gf-negative) 22%, transparent);
}

.card__header {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-block-end: 18px;

  h2 { font-size: 17px; font-weight: 650; letter-spacing: -0.01em; margin: 0; }
  p { color: var(--gf-ink-subtle); font-size: 14px; margin: 4px 0 0; }
}

.card__actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  margin-block-start: 20px;
}

/* Hero: avatar/logo, name and a line of context */
.hero {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: center;

  h1, h2 { font-size: 24px; font-weight: 650; letter-spacing: -0.02em; margin: 10px 0 0; }
  p { color: var(--gf-ink-subtle); margin: 0; max-inline-size: 46ch; }
}

.hero__image {
  block-size: 96px;
  border-radius: 50%;
  inline-size: 96px;
  object-fit: cover;
  outline: 1px solid oklch(0% 0 0 / 0.08);
  outline-offset: -1px;
}

.hero__image--square { border-radius: 24px; }

/* Avatar/logo with an upload badge */
.avatar-editor {
  display: inline-grid;
  position: relative;

  label {
    border-radius: 50%;
    cursor: pointer;
    display: grid;
    position: relative;

    &:focus-within { outline: 2px solid var(--gf-mention); outline-offset: 3px; }
  }

  input[type="file"] {
    block-size: 100%;
    cursor: pointer;
    inline-size: 100%;
    inset: 0;
    opacity: 0;
    position: absolute;
  }
}

.avatar-editor--square label { border-radius: 24px; }

.avatar-editor__badge {
  align-items: center;
  background-color: var(--gf-primary);
  block-size: 32px;
  border: 3px solid var(--gf-surface);
  border-radius: 50%;
  color: var(--gf-on-primary);
  display: flex;
  inline-size: 32px;
  inset: auto -2px -2px auto;
  justify-content: center;
  pointer-events: none;
  position: absolute;

  .icon { block-size: 15px; inline-size: 15px; }
  img { block-size: 15px; filter: invert(1); inline-size: 15px; }

  @media (prefers-color-scheme: dark) { img { filter: none; } }
}

.avatar-editor:hover .hero__image { filter: brightness(0.92); }

/* Forms */
.form {
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 6px;
  min-inline-size: 0;

  textarea.input { line-height: 1.5; min-block-size: 96px; }
}

.field__label {
  align-items: center;
  color: var(--gf-ink-subtle);
  display: flex;
  font-size: 13px;
  font-weight: 550;
  gap: 6px;
  justify-content: space-between;
}

.field__hint { color: var(--gf-ink-faint); font-size: 13px; }

/* Campfire's translate popover, as a quiet icon at the end of a label */
.field__label details > summary.btn {
  --btn-background: transparent;
  --btn-border-color: transparent;
  --btn-size: 26px;

  box-shadow: none;

  img { block-size: 15px; inline-size: 15px; opacity: 0.5; }
}

/* Setting rows: text on the left, a control on the right */
.setting {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  min-block-size: 52px;

  & + & { border-block-start: 1px solid var(--gf-border); }

  form { margin: 0; }
}

.setting__text {
  display: grid;
  gap: 2px;
  min-inline-size: 0;

  strong { font-size: 15px; font-weight: 600; }
  span { color: var(--gf-ink-subtle); font-size: 13.5px; }
}

/* Lists of people, rooms, bots, devices */
.list {
  display: flex;
  flex-direction: column;
  list-style: none;
  margin: 0;
  padding: 0;
}

.list__item {
  align-items: center;
  display: flex;
  gap: 12px;
  margin: 0;
  min-block-size: 56px;
  padding-block: 8px;

  & + & { border-block-start: 1px solid var(--gf-border); }

  &.banned { opacity: 0.55; }

  form { margin: 0; }
}

.list__avatar {
  block-size: 36px;
  border-radius: 50%;
  flex: none;
  inline-size: 36px;
  object-fit: cover;
  outline: 1px solid oklch(0% 0 0 / 0.08);
  outline-offset: -1px;
}

.list__text {
  display: grid;
  flex: 1;
  gap: 1px;
  min-inline-size: 0;

  > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

.list__title { color: var(--gf-ink); font-weight: 600; text-decoration: none; }
a.list__title:hover { text-decoration: underline; }
.list__meta { color: var(--gf-ink-subtle); font-size: 13px; }

.list__actions {
  align-items: center;
  display: flex;
  flex: none;
  gap: 6px;

  .btn { --btn-size: 34px; }
}

/* Small pills */
.badge {
  align-items: center;
  background-color: var(--gf-hover);
  border: 1px solid var(--gf-border);
  border-radius: 999px;
  color: var(--gf-ink-subtle);
  display: inline-flex;
  font-size: 12px;
  font-weight: 600;
  gap: 6px;
  padding: 3px 10px;
  white-space: nowrap;
}

.badge--live {
  /* sRGB: white has no hue, so an OKLCH mix would drift towards pink. */
  background-color: color-mix(in srgb, var(--gf-positive) 14%, var(--gf-surface));
  border-color: transparent;
  color: color-mix(in srgb, var(--gf-positive) 75%, var(--gf-ink));

  &::before {
    background-color: var(--gf-positive);
    block-size: 7px;
    border-radius: 50%;
    content: "";
    inline-size: 7px;
  }
}

/* Overlapping avatars */
.avatar-stack {
  align-items: center;
  display: flex;
  padding-inline-start: 8px;

  > * {
    align-items: center;
    background-color: var(--gf-selected);
    block-size: 30px;
    border-radius: 50%;
    display: inline-flex;
    font-size: 12px;
    font-weight: 650;
    inline-size: 30px;
    justify-content: center;
    margin-inline-start: -8px;
    object-fit: cover;
    outline: 2px solid var(--gf-surface);
  }

  .avatar-stack__more {
    background-color: var(--gf-ink);
    color: var(--gf-on-primary);
  }
}

/* Inline copy field (invite and sign-in links) */
.copy-field {
  align-items: center;
  display: flex;
  gap: 8px;

  .input { flex: 1; font-size: 14px; min-inline-size: 0; text-overflow: ellipsis; }
}

@media (max-width: 100ch) {
  body.app:not(.sidebar, .card-page) #nav { padding-inline: 12px 16px; }
}

/* Buttons with an icon and a label */
.btn--labeled,
.btn:has(> .icon) {
  --btn-padding: 0 16px 0 14px;

  gap: 8px;

  .icon { block-size: 18px; inline-size: 18px; }
}

/* Account identity: logo, name, remove logo */
.account-identity {
  align-items: center;
  display: flex;
  gap: 18px;

  .account-identity__name { flex: 1; }
  .account-identity__title { font-size: 22px; font-weight: 650; margin: 0; }
  .hero__image { block-size: 72px; inline-size: 72px; }
}

/* Setting rows that navigate */
.setting--link {
  border-radius: 12px;
  color: inherit;
  margin-inline: -10px;
  padding-inline: 10px;
  text-decoration: none;

  .icon { color: var(--gf-ink-faint); flex: none; }
  &:hover { background-color: var(--gf-hover); }
  &:hover + .setting, & + .setting--link { border-color: transparent; }
}

/* Admin crown toggle in people lists */
.role-toggle {
  img { opacity: 0.35; }
  &:has(input:checked) { --btn-background: var(--gf-brand-soft); --btn-border-color: transparent; }
  &:has(input:checked) img { opacity: 1; }
}

/* Member pickers (room and meeting forms) */
.member-picker {
  background-color: var(--gf-hover);
  border-radius: 16px;
  max-block-size: 420px;
  overflow-y: auto;
  padding: 4px 14px;

  .list__item + .list__item { border-color: var(--gf-border); }
}

.member-picker__filter { margin: 10px 0 4px; }

.member-picker__divider {
  border-block-start: 2px solid var(--gf-border-strong);
  list-style: none;
  margin-block: 4px;
}

.access-choice {
  background-color: var(--gf-hover);
  border-radius: 16px;
  padding: 8px 14px;
}

/* Chat bots: commands per room */
.bot-room {
  background-color: var(--gf-hover);
  border-radius: 16px;
  display: grid;
  gap: 8px;
  margin-block-start: 12px;
  padding: 12px 14px;

  .copy-field .input { font-size: 12.5px; }
}

.bot-room__name { align-items: center; display: flex; gap: 8px; }
.bot-room__kind { color: var(--gf-ink-faint); display: inline-flex; .icon { block-size: 18px; inline-size: 18px; } }

/* Search */
.search-bar {
  align-items: center;
  display: flex;
  flex: none;
  gap: 10px;
  padding: 18px 24px 6px;

  @media (max-width: 100ch) { padding: 12px 14px 6px; }
}

.search-bar__field {
  --input-border-radius: 999px;
  --input-padding: 0 8px 0 16px;

  color: var(--gf-ink-faint);
  display: flex;
  flex: 1;
  gap: 10px;
  min-block-size: 48px;

  .icon { block-size: 18px; flex: none; inline-size: 18px; }
  .input { font-size: 16px; padding: 0; }

  .searches__reset {
    align-items: center;
    border-radius: 50%;
    color: var(--gf-ink-subtle);
    display: inline-flex;
    flex: none;
    block-size: 30px;
    inline-size: 30px;
    justify-content: center;

    &:hover { background-color: var(--gf-hover); }
  }
}

.search-bar .btn { min-block-size: 48px; --btn-padding: 0 22px; }

.search-summary {
  color: var(--gf-ink-subtle);
  flex: none;
  font-size: 13.5px;
  margin: 4px 24px 0;
}

.recent-searches {
  flex: none;
  padding: 10px 24px 0;

  @media (max-width: 100ch) { padding-inline: 14px; }
}

.recent-searches__header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-block-end: 8px;

  h2 { color: var(--gf-ink-faint); font-size: 12.5px; font-weight: 500; margin: 0; }
}

.recent-searches__clear {
  background: none;
  border: 0;
  border-radius: 8px;
  color: var(--gf-ink-subtle);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  padding: 4px 8px;

  &:hover { background-color: var(--gf-hover); color: var(--gf-ink); }
}

.recent-searches__list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.recent-searches__item {
  align-items: center;
  background-color: var(--gf-hover);
  border-radius: 999px;
  color: var(--gf-ink);
  display: inline-flex;
  font-size: 14px;
  gap: 6px;
  max-inline-size: 28ch;
  padding: 6px 14px 6px 10px;
  text-decoration: none;

  .icon { block-size: 14px; color: var(--gf-ink-faint); flex: none; inline-size: 14px; }
  span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  &:hover { background-color: var(--gf-selected); }
}

.search-empty { color: var(--gf-ink-subtle); margin: 8px 0 0; text-align: center; }

.searches .message__room a { color: var(--gf-ink-subtle); }

/* Meetings: a history list in the white card, newest first; live calls on top */
.meetings-history {
  inline-size: 100%;
  padding: 4px 16px 32px;

  @media (max-width: 100ch) { padding: 0 6px 24px; }
}

.call-list {
  display: flex;
  flex-direction: column;
  list-style: none;
  margin: 0;
  padding: 0;
}

.call-row {
  align-items: center;
  border-radius: 16px;
  display: grid;
  gap: 14px;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  padding: 12px;
  position: relative;

  /* Hairlines between rows, inset to the content; hidden around the hovered row */
  & + &::before {
    border-block-start: 1px solid var(--gf-border);
    content: "";
    inset: 0 12px auto;
    position: absolute;
  }

  &:hover { background-color: var(--gf-hover); }
  &:hover::before,
  &:hover + &::before { visibility: hidden; }

  @media (max-width: 100ch) {
    grid-template-areas: "icon main actions" "icon people actions";
    grid-template-columns: auto minmax(0, 1fr) auto;
    row-gap: 6px;

    .call-row__icon { grid-area: icon; align-self: start; }
    .call-row__main { grid-area: main; }
    .avatar-stack { grid-area: people; justify-self: start; }
    .call-row__actions { grid-area: actions; }
  }
}

/* Icon tile: concentric with the row (16 = 10 + 6) */
.call-row__icon {
  align-items: center;
  background-color: var(--gf-hover);
  block-size: 42px;
  border-radius: 12px;
  color: var(--gf-ink-subtle);
  display: inline-flex;
  inline-size: 42px;
  justify-content: center;

  .icon { block-size: 19px; inline-size: 19px; }

  .call-row:hover & { background-color: var(--gf-surface); box-shadow: 0 0 0 1px var(--gf-border); }

  /* Mixed in sRGB: white has no hue, so an OKLCH mix would drift towards pink. */
  .call-row--live & {
    background-color: color-mix(in srgb, var(--gf-positive) 14%, var(--gf-surface));
    color: color-mix(in srgb, var(--gf-positive) 85%, var(--gf-ink));
  }
}

.call-row__main { min-inline-size: 0; }

.call-row__title {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;

  a {
    color: var(--gf-ink);
    font-size: 15.5px;
    font-weight: 650;
    min-inline-size: 0;
    overflow: hidden;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;

    &:hover { text-decoration: underline; }
  }
}

.call-row__meta {
  color: var(--gf-ink-subtle);
  font-size: 13.5px;
  margin-block-start: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;

  time { font-variant-numeric: tabular-nums; }

  .call-row--new & { color: var(--gf-ink-faint); }
}

.call-row .avatar-stack > * { outline-color: var(--gf-surface); }
.call-row:hover .avatar-stack > * { outline-color: var(--gf-hover); }

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

.call-row__tool {
  align-items: center;
  background: transparent;
  block-size: 34px;
  border: 0;
  border-radius: 50%;
  color: var(--gf-ink-faint);
  cursor: pointer;
  display: inline-flex;
  inline-size: 34px;
  justify-content: center;

  .icon { block-size: 17px; inline-size: 17px; }
  &:hover { background-color: var(--gf-selected); color: var(--gf-ink); }
  &:focus-visible { outline: 2px solid var(--gf-mention); outline-offset: 1px; }

  &.call-row__tool--copied { color: var(--gf-positive); }

  @media (max-width: 100ch) { display: none; }
}

.call-row__join {
  --btn-size: 36px;
  --btn-padding: 0 16px;

  margin-inline-start: 4px;
  white-space: nowrap;
}

#nav .meetings__new {
  --btn-padding: 0 16px 0 12px;

  gap: 6px;

  .icon { block-size: 18px; inline-size: 18px; }
}

.stat__icon {
  align-items: center;
  color: var(--gf-ink-subtle);
  display: inline-flex;

  .icon { block-size: 20px; inline-size: 20px; }
}

.section-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-block-end: 12px;

  h2 { font-size: 18px; font-weight: 650; letter-spacing: -0.01em; margin: 0; }
}

.empty-state {
  align-items: center;
  display: grid;
  gap: 8px;
  justify-items: center;
  padding: 40px 24px;
  text-align: center;

  h3 { font-size: 17px; margin: 4px 0 0; }
  p { color: var(--gf-ink-subtle); margin: 0 0 8px; max-inline-size: 44ch; }
}

/* Account footer credits */
body.app:not(.sidebar, .card-page) #footer {
  color: var(--gf-ink-faint);
  font-size: 13px;
  padding-block-end: 32px;
}
