/* v2 settings surfaces: a small-caps group label sits above an outlined card
   whose direct children read as rows divided by hairlines. Toggle rows are the
   shared .setting-row (inputs.css); this file carries the card, the labelled
   field, and the page header. */

.settings-label {
  color: var(--color-text-subtle);
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  margin: 0 0 8px 2px;
  text-transform: uppercase;
}

* + .settings-label {
  margin-block-start: 22px;
}

.settings-card {
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding-inline: 18px;

  /* Sibling cards keep the comp's 16px rhythm without needing a label row */
  & + & {
    margin-block-start: 16px;
  }

  /* A text button at a row's end keeps its shape instead of squashing
     against the row text */
  .setting-row .btn {
    flex-shrink: 0;
    white-space: nowrap;
  }

  > * {
    padding-block: 14px;
  }

  > * + * {
    border-block-start: 1px solid var(--color-border);
  }

  /* rows bring no padding of their own — the card spaces its children */
  .setting-row {
    padding-block: 0;
  }

  /* ...except a setting-row that IS a direct child (no form wrapper to carry the
     14px), which the reset above would otherwise strip to a flush, padding-less
     row. */
  > .setting-row {
    padding-block: 14px;
  }
}

/* Page header: scope eyebrow, title, one-line blurb */
.settings-header {
  margin-block-end: 22px;
}

.settings-header__scope {
  color: var(--color-text-subtle);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.settings-header__title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin: 5px 0 0;
}

.settings-header__blurb {
  color: var(--color-text-muted);
  font-size: 0.875rem;
  line-height: 1.5;
  margin: 6px 0 0;
}

/* Labelled field: label row above the input */
.settings-field {
  & + & {
    margin-block-start: 14px;
  }
}

.settings-field__label {
  align-items: center;
  color: var(--color-text-muted);
  display: flex;
  font-size: 0.78125rem;
  font-weight: 700;
  justify-content: space-between;
  margin-block-end: 6px;
}

.settings-field .input {
  background-color: var(--color-bg);
  border-radius: 8px;
  inline-size: 100%;
  padding: 9px 12px;
}

.settings-field__hint {
  color: var(--color-text-subtle);
  font-size: 0.78125rem;
  margin: 6px 0 0;
}

/* The bot invite-code row is a bare flex row rendered straight under its
   explainer, so give it a clear break from the hint above it. */
.settings-field #bot_invite_code {
  margin-block-start: 14px;
}

/* Invitations: join-link card internals. The head and the URL row form one
   group so the card's hairlines fall only before the setting rows below. */
.invite-link__head {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.invite-status {
  border-radius: 5px;
  flex-shrink: 0;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 2px 8px;
  text-transform: uppercase;
}

.invite-status--alert {
  background-color: color-mix(in srgb, var(--color-alert) 14%, transparent);
  color: var(--color-alert);
}

.invite-status--active {
  background-color: color-mix(in srgb, var(--color-positive) 14%, transparent);
  color: var(--color-positive);
}

.invite-url-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-block-start: 12px;

  .btn {
    flex-shrink: 0;
  }
}

.invite-url-input {
  background-color: var(--color-bg-sunk);
  border: 1px solid var(--color-border-dark);
  border-radius: 8px;
  color: var(--color-text-muted);
  flex: 1;
  font-family: var(--font-mono);
  font-size: 0.84375rem;
  min-inline-size: 12ch;
  padding: 9px 12px;
}

.settings-footnote {
  color: var(--color-text-subtle);
  font-size: 0.78125rem;
  line-height: 1.55;
  margin: 14px 0 0;
}

/* ---------------------------------------------------------------------------
   Bots & webhooks — a settings-card list of rows with inline actions, plus the
   editor / bearer-key / remove dialogs. The list wrapper takes no block padding
   of its own; each row supplies its own padding and the hairline between rows.
   --------------------------------------------------------------------------- */
.settings-card > .bots-list {
  padding-block: 0;
}

.bots-list > .bot-row {
  padding-block: 14px;
}

.bots-list > .bot-row + .bot-row,
.bots-list > .bot-empty {
  border-block-start: 1px solid var(--color-border);
}

.bot-row {
  align-items: center;
  display: flex;
  gap: 12px;
}

.bot-row__avatar {
  --avatar-size: 32px;
  flex-shrink: 0;
  margin: 0;
}

.bot-row__body {
  flex: 1;
  min-inline-size: 0;
}

.bot-row__name {
  align-items: center;
  display: flex;
  font-size: 0.875rem;
  font-weight: 600;
  gap: 7px;
}

.bot-tag {
  border: 1px solid var(--color-border);
  border-radius: 4px;
  color: var(--color-text-subtle);
  flex-shrink: 0;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 1px 5px;
  text-transform: uppercase;
}

.bot-row__meta,
.bot-row__hook {
  color: var(--color-text-subtle);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bot-row__meta {
  font-size: 0.78125rem;
  margin-block-start: 2px;
}

.bot-row__hook {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  margin-block-start: 3px;
}

.bot-row__actions {
  align-items: center;
  display: flex;
  flex-shrink: 0;
  gap: 14px;

  form {
    display: flex;
    margin: 0;
  }
}

.bot-action {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.78125rem;
  font-weight: 600;
  padding: 0;
  text-decoration: none;
  white-space: nowrap;
  --hover-size: 0;
}

.bot-action--danger {
  color: var(--color-text-subtle);

  &:hover {
    color: var(--color-negative);
  }
}

.bot-empty {
  padding-block: 32px;
  text-align: center;
}

.bot-empty__title {
  font-size: 0.9375rem;
  font-weight: 700;
  margin: 0;
}

.bot-empty__body {
  color: var(--color-text-muted);
  font-size: 0.8125rem;
  line-height: 1.5;
  margin: 6px auto 0;
  max-inline-size: 42ch;
}

.bot-footer {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;

  .btn {
    flex-shrink: 0;
    white-space: nowrap;
  }
}

.bot-footer__text {
  color: var(--color-text-muted);
  font-size: 0.8125rem;
  line-height: 1.5;
}

/* Dialogs */
.scrim-dialog--bot-editor {
  --dialog-width: 560px;
}

/* Align the field column's side padding with the titled header (18px) so the
   title and inputs share one left edge, and tighten the gap under the header. */
.scrim-dialog--bot-editor .scrim-dialog__body {
  padding: 12px 18px;
}

/* The footer sits inside the padded form body, so it drops its own side padding
   (the body already insets 18px, lining the buttons up with the fields) and adds
   a top gap so the divider isn't glued to the room hint. */
.scrim-dialog--bot-editor .scrim-dialog__footer {
  margin-block-start: 16px;
  padding: 14px 0 0;
}

.scrim-dialog--bot-key {
  --dialog-width: 440px;
}

.scrim-dialog--bot-remove {
  --dialog-width: 400px;
}

/* Room multi-select chips: a hidden checkbox fills the label on :checked. */
.room-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.room-chip {
  align-items: center;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  color: var(--color-text-muted);
  cursor: pointer;
  display: inline-flex;
  font-size: 0.78125rem;
  font-weight: 600;
  line-height: 1;
  min-block-size: 30px;
  padding: 0 12px;

  &:has(:checked) {
    background-color: var(--color-selected);
    border-color: var(--color-accent-brand);
    color: var(--color-accent-brand);
  }

  &:has(:focus-visible) {
    outline: 2px solid var(--color-link);
    outline-offset: 2px;
  }
}

/* The "#" channel sigil is decorative — it inherits the chip color, so it turns
   accent along with the label when selected, and stays out of the form value. */
.room-chip__label::before {
  content: "#";
}

/* Bearer-key dialog: the title flows straight into the lead line with no rule,
   matching the design (the shared header border is dropped for this dialog). */
.scrim-dialog--bot-key .scrim-dialog__header {
  border-block-end: none;
  padding-block-end: 4px;
}

.bot-key__lead {
  line-height: 1.5;
  margin-block-end: 14px;
}

.bot-key {
  align-items: center;
  background-color: var(--color-bg-sunk);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  display: flex;
  gap: 10px;
  margin-block-end: 12px;
  padding: 12px 13px;
}

.bot-key__value {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 0.78125rem;
  min-inline-size: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Copy reads as an accent text-link inside the key field, not a bordered button. */
.bot-key__copy {
  color: var(--color-accent-brand);
  flex-shrink: 0;
  font-weight: 600;
}

/* The auth-scheme hint is inline mono that flows with the muted sentence around
   it — no boxed <code> treatment. */
.key-scheme {
  font-family: var(--font-mono);
}

.bot-key__done {
  inline-size: 100%;
  justify-content: center;
  margin-block-start: 14px;
}

/* Destructive remove dialog: keep the danger fill on the confirm button, which
   the footer's quiet-button rule would otherwise flatten. */
.bot-remove-warning {
  background-color: var(--color-bg-negative);
  border-radius: 10px;
  color: var(--color-text-lighter);
  font-size: 0.8125rem;
  line-height: 1.55;
  padding: 13px 14px;
}

.scrim-dialog--bot-remove .scrim-dialog__footer .btn--negative {
  --btn-background: var(--color-negative);
  --btn-border-color: var(--color-negative);
  --btn-color: var(--color-text-reversed);
}

/* ---------------------------------------------------------------------------
   Badges — a settings-card of definition rows (chip · holders · hex · actions),
   an editor dialog led by a live chip preview over hue swatches, and a
   destructive delete dialog that names the holders. The chip reuses
   .member-badge everywhere it renders.
   --------------------------------------------------------------------------- */
.settings-card > .badges-list {
  padding-block: 0;
}

.badges-list > .badge-row {
  padding-block: 13px;
}

.badges-list > .badge-row + .badge-row {
  border-block-start: 1px solid var(--color-border);
}

.badge-row {
  align-items: center;
  display: flex;
  gap: 12px;
}

.badge-row__chip {
  flex-shrink: 0;
}

.badge-row__holders {
  color: var(--color-text-muted);
  flex: 1;
  font-size: 0.8125rem;
  min-inline-size: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge-row__hex {
  color: var(--color-text-subtle);
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.badge-row__actions {
  align-items: center;
  display: flex;
  flex-shrink: 0;
  gap: 14px;

  form {
    display: flex;
    margin: 0;
  }
}

.badge-action {
  --hover-size: 0;

  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.78125rem;
  font-weight: 600;
  padding: 0;
  text-decoration: none;
  white-space: nowrap;
}

.badge-action--danger {
  color: var(--color-text-subtle);

  &:hover {
    color: var(--color-negative);
  }
}

.badge-footer {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;

  .btn {
    flex-shrink: 0;
    white-space: nowrap;
  }
}

.badge-footer__text {
  color: var(--color-text-muted);
  font-size: 0.8125rem;
  line-height: 1.5;
}

.badges-empty {
  padding-block: 32px;
  text-align: center;
}

.badges-empty__title {
  font-size: 0.9375rem;
  font-weight: 700;
}

.badges-empty__body {
  color: var(--color-text-muted);
  font-size: 0.8125rem;
  line-height: 1.5;
  margin: 6px auto 0;
  max-inline-size: 46ch;
}

.scrim-dialog--badge-editor {
  --dialog-width: 440px;
}

.scrim-dialog--badge-editor .scrim-dialog__body {
  padding: 16px 18px;
}

.scrim-dialog--badge-editor .scrim-dialog__footer {
  margin-block-start: 16px;
  padding: 14px 0 0;
}

.scrim-dialog--badge-remove {
  --dialog-width: 400px;
}

/* The chip preview leads the form — it's the whole point of the dialog. */
.badge-preview-wrap {
  align-items: center;
  background-color: var(--color-bg-sunk);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  display: flex;
  justify-content: center;
  margin-block-end: 18px;
  padding: 22px;
}

.badge-preview {
  font-size: 0.75rem;
  padding: 3px 9px;
}

.badge-counter,
.badge-hex {
  color: var(--color-text-subtle);
  font-size: 0.71875rem;
  font-weight: 600;
}

.badge-hex {
  font-family: var(--font-mono);
}

/* Free colour picker: the native swatch styled to the 36px field height. */
.color-picker {
  background: var(--color-bg);
  block-size: 36px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  cursor: pointer;
  inline-size: 100%;
  padding: 4px;

  &::-webkit-color-swatch-wrapper {
    padding: 0;
  }

  &::-webkit-color-swatch {
    border: none;
    border-radius: 5px;
  }

  &::-moz-color-swatch {
    border: none;
    border-radius: 5px;
  }
}

.badge-remove-warning {
  background-color: var(--color-bg-negative);
  border-radius: 10px;
  color: var(--color-text-lighter);
  font-size: 0.8125rem;
  line-height: 1.55;
  padding: 13px 14px;
}

.scrim-dialog--badge-remove .scrim-dialog__footer .btn--negative {
  --btn-background: var(--color-negative);
  --btn-border-color: var(--color-negative);
  --btn-color: var(--color-text-reversed);
}

/* Inline field validation: red border plus the matching 3px negative ring. */
.input--negative {
  --input-border-color: var(--color-negative);
  box-shadow: 0 0 0 3px var(--color-bg-negative);
}

.field-error {
  color: var(--color-negative);
  font-size: 0.78125rem;
  font-weight: 600;
  margin: 6px 0 0;
}

/* Accent save/submit chip */
.btn.settings-save {
  --btn-background: var(--color-accent-brand);
  --btn-border-color: var(--color-accent-brand);
  --btn-border-radius: 8px;
  --btn-color: var(--color-text-reversed);
  --btn-padding: 9px 18px;

  font-size: 0.8125rem;
  font-weight: 600;
}

/* Quiet outlined chip (Upload / Shuffle / Replace logo) */
.btn.settings-chip-btn {
  --btn-background: transparent;
  --btn-border-color: var(--color-border);
  --btn-border-radius: 8px;
  --btn-color: var(--color-text-muted);
  --btn-padding: 7px 13px;
  --hover-color: transparent;
  --hover-filter: none;

  font-size: 0.8125rem;
  font-weight: 600;
  position: relative;

  /* Soft fill on hover, not the default .btn border-darker ring */
  @media (any-hover: hover) {
    &:hover {
      --btn-background: var(--color-bg-hover);
    }
  }

  input[type="file"] {
    cursor: pointer;
    inset: 0;
    opacity: 0;
    position: absolute;

    &::file-selector-button {
      cursor: pointer;
    }
  }
}

/* Avatar/logo row at the top of a profile card */
.settings-avatar-row {
  align-items: center;
  display: flex;
  gap: 14px;

  .btn.avatar {
    --btn-size: 56px;

    flex: none;
  }
}

.btn.settings-chip-btn--negative {
  --btn-color: var(--color-negative);
}

/* Accent picker: five paint-chip swatches, ring on the chosen one */
.accent-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.accent-swatch {
  align-items: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.accent-swatch__dot {
  background-color: var(--swatch-color);
  block-size: 22px;
  border-radius: 50%;
  inline-size: 22px;
}

.accent-swatch:has(input:checked) .accent-swatch__dot {
  box-shadow:
    0 0 0 2px var(--color-bg),
    0 0 0 4px var(--color-text);
}

.accent-swatch:has(input:focus-visible) .accent-swatch__dot {
  outline: 2px solid var(--color-link);
  outline-offset: 2px;
}

.accent-swatch__name {
  color: var(--color-text-subtle);
  font-size: 0.6875rem;
  font-weight: 600;
}

.accent-swatch:has(input:checked) .accent-swatch__name {
  color: var(--color-text);
}

/* Two-pane settings shell: a fixed section nav beside a scrolling content
   column. Below 834 the nav flattens into a scrollable chip row on top. */
body.settings #main-content {
  justify-content: stretch;
  overflow: hidden;
}

/* v2.1 settings have no top chrome bar — the content header is the top-most
   element. Above the docked-sidebar breakpoint there is no hamburger, so the
   bar is pure redundant chrome and collapses away; below it the bare bar stays
   to host the sidebar toggle. */
@media (min-width: 1280px) {
  body.settings #nav {
    display: none;
  }
}

.settings-split {
  display: flex;
  flex: 1 1 auto;
  min-block-size: 0;
}

.settings-nav {
  border-inline-end: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  inline-size: 236px;
  overflow-y: auto;
  padding: 20px 10px;
}

.settings-nav__header {
  padding: 0 12px 14px;
}

.settings-nav__title {
  font-size: 1.1875rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}

.settings-nav__sub {
  align-items: center;
  display: flex;
  gap: 7px;
  margin: 5px 0 0;
}

.settings-nav__sub-name {
  color: var(--color-text-muted);
  font-size: 0.78125rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-nav__chip {
  background-color: var(--color-selected);
  border-radius: 4px;
  color: var(--color-accent-brand);
  flex-shrink: 0;
  font-size: 0.59375rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 1px 5px;
  text-transform: uppercase;
}

.settings-nav__label {
  color: var(--color-text-subtle);
  display: block;
  font-size: 0.65625rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  padding: 0 12px 6px;
  text-transform: uppercase;
}

.settings-nav__item {
  border-radius: 8px;
  color: var(--color-text-muted);
  display: block;
  font-size: 0.875rem;
  padding: 7px 12px;
  text-decoration: none;

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

  &[aria-current="page"] {
    background-color: var(--color-selected);
    color: var(--color-accent-brand);
    font-weight: 600;
  }
}

.settings-nav__switch {
  --icon-size: 16px;

  align-items: center;
  border-block-start: 1px solid var(--color-border);
  color: var(--color-text-muted);
  display: flex;
  font-size: 0.84375rem;
  font-weight: 600;
  gap: 8px;
  margin: 6px 4px 0;
  padding: 9px 12px;
  text-decoration: none;

  &:hover {
    color: var(--color-accent-brand);
  }
}

.settings-nav__switch-label {
  flex: 1;
}

.settings-split__content {
  flex: 1 1 auto;
  min-inline-size: 0;
  overflow-y: auto;
}

.settings-split__inner {
  max-inline-size: 660px;
  padding: 30px 34px 60px;

  @media (max-width: 1023.9px) {
    padding: 24px 20px 48px;
  }
}

@media (max-width: 833.9px) {
  .settings-split {
    display: block;
    overflow-y: auto;
  }

  .settings-nav {
    align-items: center;
    border-block-end: 1px solid var(--color-border);
    border-inline-end: 0;
    flex-direction: row;
    gap: 4px;
    inline-size: auto;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px 12px;
  }

  .settings-nav__header,
  .settings-nav__label {
    display: none;
  }

  .settings-nav__group {
    display: flex;
    gap: 4px;
  }

  .settings-nav__item {
    white-space: nowrap;
  }

  .settings-nav__switch {
    border-block-start: 0;
    flex-shrink: 0;
    margin: 0;
    padding: 7px 12px;
    white-space: nowrap;
  }
}

