.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 38px;
  padding: 0 var(--space-4);
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--text-on-accent);
  font-size: var(--step--1);
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  transition:
    background-color 0.16s var(--ease-out),
    opacity 0.16s var(--ease-out);
}

.button > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.button:hover:not(:disabled) {
  background: var(--accent-hover);
}

.button:disabled {
  opacity: 0.5;
}

.button--secondary {
  background: var(--bg-raised);
  color: var(--text-normal);
}

.button--secondary:hover:not(:disabled) {
  background: var(--button-secondary-hover);
}

.button--ghost {
  background: transparent;
  color: var(--text-muted);
}

.button--ghost:hover:not(:disabled) {
  background: var(--bg-raised);
  color: var(--text-strong);
}

.button--positive {
  background: var(--positive);
  color: var(--text-on-accent);
}

.button--positive:hover:not(:disabled) {
  background: var(--positive-hover);
}

.button--danger-ghost {
  background: transparent;
  color: var(--danger);
}

.button--danger-ghost:hover:not(:disabled) {
  background: var(--danger-quiet);
  color: var(--danger-text);
}

.button--danger {
  background: var(--danger);
}

.button--danger:hover:not(:disabled) {
  background: var(--danger-hover);
}

.button--small {
  min-height: 32px;
  padding: 0 var(--space-3);
  font-size: var(--step--2);
}

.button--icon {
  padding: 0;
  width: 34px;
  min-height: 34px;
}

.button__spinner {
  flex: none;
  width: 14px;
  height: 14px;
  border: 2px solid var(--ring-strong);
  border-color: rgb(from currentColor r g b / 0.3);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.button[aria-busy="true"]:disabled {
  opacity: 0.85;
  cursor: progress;
}

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

.progress {
  position: fixed;
  inset: 0 0 auto;
  z-index: 200;
  height: 2px;
  background: transparent;
  pointer-events: none;
}

.progress::after {
  content: "";
  display: block;
  height: 100%;
  width: 100%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-line);
  transform: scaleX(0);
  transform-origin: 0 50%;
}

.progress--running::after {
  transform: scaleX(0.88);
  transition: transform 8s cubic-bezier(0.05, 0.7, 0.15, 1);
}

.progress--done::after {
  transform: scaleX(1);
  transition:
    transform 0.14s var(--ease-out),
    opacity 0.22s ease 0.1s;
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  .button__spinner {
    animation-duration: 1.6s;
  }

  .progress--running::after,
  .progress--done::after {
    transition: none;
  }

  .progress--running::after {
    transform: scaleX(1);
    opacity: 0.6;
  }
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.field__label {
  font-size: var(--step--2);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.field__hint {
  font-size: var(--step--1);
  color: var(--text-faint);
}

.field__error {
  font-size: var(--step--1);
  color: var(--danger);
}

.input,
.select,
.textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-strong);
  caret-color: var(--accent);
  transition: border-color 0.16s var(--ease-out);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-faint);
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: var(--line-soft);
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--focus);
}

.input:focus:not(:focus-visible),
.select:focus:not(:focus-visible),
.textarea:focus:not(:focus-visible) {
  outline: none;
}

.input:disabled,
.select:disabled,
.textarea:disabled {
  color: var(--text-faint);
  cursor: not-allowed;
}

.textarea {
  resize: vertical;
  min-height: 88px;
  line-height: 1.5;
}

.select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% + 1px),
    calc(100% - 13px) calc(50% + 1px);
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch__track {
  width: 40px;
  height: 24px;
  border-radius: var(--radius-pill);
  background: var(--switch-off);
  position: relative;
  transition: background-color 0.16s var(--ease-out);
  flex: none;
}

.switch__track::after {
  content: "";
  position: absolute;
  inset: 4px auto 4px 4px;
  width: 16px;
  border-radius: 50%;
  background: var(--switch-knob);
  transition: transform 0.16s var(--ease-out);
}

.switch input:checked + .switch__track {
  background: var(--positive);
}

.switch input:checked + .switch__track::after {
  transform: translateX(16px);
}

.switch input:focus-visible + .switch__track {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.switch input:disabled + .switch__track {
  opacity: 0.5;
  cursor: not-allowed;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: var(--bg-raised);
  color: var(--text-muted);
  font-size: var(--step--2);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.chip--accent {
  background: var(--accent-quiet);
  color: var(--accent-text);
}

.chip--positive {
  background: var(--positive-quiet);
  color: var(--positive-text);
}

.chip--caution {
  background: var(--caution-quiet);
  color: var(--caution-text);
}

.chip--danger {
  background: var(--danger-quiet);
  color: var(--danger-text);
}

.chip--gold {
  background: var(--gold-quiet);
  color: var(--gold-text);
}

.chip__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.alert {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  background: var(--caution-quiet);
  color: var(--caution-text);
  font-size: var(--step--1);
}

.alert--danger {
  background: var(--danger-quiet);
  color: var(--danger-text);
}

.alert__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.alert__title {
  font-weight: 700;
  color: inherit;
}

.alert__body .button {
  align-self: flex-start;
  margin-top: var(--space-1);
}

.alert ul {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.alert li::before {
  content: "\2013";
  margin-right: var(--space-2);
  opacity: 0.6;
}

.panel {
  min-width: 0;
  background: var(--bg-sunken);
  border-radius: var(--radius-md);
  padding: var(--space-5);
}

.panel__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.panel__title {
  font-size: var(--step-0);
  font-weight: 700;
  color: var(--text-strong);
}

.panel__meta {
  font-size: var(--step--1);
  color: var(--text-faint);
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-7) var(--space-5);
  text-align: center;
  color: var(--text-faint);
}

.empty .icon {
  width: 2.5rem;
  height: 2.5rem;
  color: var(--line-strong);
}

.empty__title {
  color: var(--text-muted);
  font-weight: 600;
}

.empty__body {
  font-size: var(--step--1);
  max-width: 46ch;
}

.shortcuts {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.shortcuts__row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.shortcuts__keys {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--space-1);
  width: 108px;
}

.shortcuts__key {
  min-width: 26px;
  padding: 3px 7px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  box-shadow: inset 0 -2px 0 var(--shadow-key);
  color: var(--text-strong);
  font-family: var(--font-mono);
  font-size: var(--step--2);
  text-align: center;
}

.shortcuts__joiner {
  font-size: var(--step--2);
  color: var(--text-faint);
}

.shortcuts__what {
  font-size: var(--step--1);
  color: var(--text-muted);
}

.toast-stack {
  position: fixed;
  right: var(--space-5);
  bottom: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 300;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-raised);
  color: var(--text-strong);
  box-shadow: var(--shadow-high);
  font-size: var(--step--1);
  max-width: 360px;
  animation: toast-in 0.24s var(--ease-out) both;
}

.toast--action {
  pointer-events: auto;
  padding-right: var(--space-2);
}

.toast--action .button {
  flex: none;
  margin-left: auto;
  color: inherit;
}

.toast--action .button:hover:not(:disabled) {
  background: var(--wash-4);
  color: inherit;
}

.toast--error {
  background: var(--danger-surface);
  color: var(--danger-surface-text);
}

.toast--success {
  background: var(--positive-surface);
  color: var(--positive-surface-text);
}

.toast--caution {
  background: var(--caution-surface);
  color: var(--caution-text);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  display: grid;
  place-items: center;
  padding: var(--space-5);
  z-index: 50;
}

.dialog {
  width: min(440px, 100%);
  background: var(--bg-canvas);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-high);
  overflow: hidden;
}

.dialog--wide {
  width: min(560px, 100%);
  max-height: min(680px, 100%);
  display: flex;
  flex-direction: column;
}

.dialog__body {
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.dialog__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--line-soft);
}

.dialog__head h3 {
  font-size: var(--step-1);
}

.dialog__scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding-top: var(--space-2);
  border-top: 1px solid var(--line-soft);
}

.pager__label {
  font-size: var(--step--1);
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.dialog__footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background: var(--bg-sunken);
}

.meter {
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--bg-input);
  overflow: hidden;
}

.meter__fill {
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: var(--accent);
  clip-path: inset(0 calc(100% - var(--fill, 0%)) 0 0 round var(--radius-pill));
  transition: clip-path 0.4s var(--ease-out);
}

.meter__fill--positive {
  background: var(--positive);
}

.meter__fill--gold {
  background: var(--gold);
}

.discord-preview {
  background: var(--bg-canvas);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  display: flex;
  gap: var(--space-4);
}

.discord-preview__avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  display: grid;
  place-items: center;
  color: var(--text-on-accent);
  flex: none;
}

.discord-preview__avatar .icon {
  width: 1.5rem;
  height: 1.5rem;
}

.discord-preview__main {
  min-width: 0;
  flex: 1;
}

.discord-preview__head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: 2px;
}

.discord-preview__author {
  color: var(--text-strong);
  font-weight: 600;
}

.discord-preview__badge {
  background: var(--accent);
  color: var(--text-on-accent);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 4px;
  border-radius: 3px;
  text-transform: uppercase;
}

.discord-preview__time {
  font-size: var(--step--2);
  color: var(--text-faint);
}

.discord-preview__content {
  color: var(--text-normal);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin-bottom: var(--space-2);
}

.embed {
  position: relative;
  display: grid;
  gap: var(--space-2);
  max-width: 520px;
  padding: var(--space-4);
  padding-left: calc(var(--space-4) + 4px);
  background: var(--bg-sunken);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.embed__accent {
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--accent);
}

.embed__title {
  color: var(--text-strong);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.embed__description {
  font-size: var(--step--1);
  color: var(--text-normal);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.embed__field-name {
  font-size: var(--step--1);
  font-weight: 700;
  color: var(--text-strong);
}

.embed__image {
  border-radius: var(--radius-sm);
  margin-top: var(--space-1);
}

.embed--thumbed {
  padding-right: calc(var(--space-4) + 92px);
}

.embed__thumbnail {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.dtp {
  position: relative;
}

.dtp__trigger {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-strong);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.16s var(--ease-out);
}

.dtp__trigger:hover:not(:disabled) {
  border-color: var(--line-soft);
}

.dtp__trigger[aria-expanded="true"] {
  border-color: var(--focus);
}

.dtp__trigger:disabled {
  color: var(--text-faint);
  cursor: not-allowed;
}

.dtp__trigger .icon {
  flex: none;
  color: var(--text-faint);
}

.dtp__value {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dtp__trigger[data-empty="true"] .dtp__value {
  color: var(--text-faint);
}

.dtp__zone {
  flex: none;
  font-size: var(--step--2);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-faint);
}

.dtp__echo {
  margin-top: var(--space-1);
  font-size: var(--step--2);
  color: var(--text-faint);
}

.unsaved {
  position: sticky;
  bottom: var(--space-4);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-5);
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
  background: var(--bg-abyss);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-high);
  color: var(--text-strong);
  font-size: var(--step--1);
  transition:
    opacity 0.14s var(--ease-out),
    transform 0.14s var(--ease-out),
    visibility 0s linear 0.14s;
}

.unsaved[data-shown="true"] {
  visibility: visible;
  transition:
    opacity 0.14s var(--ease-out),
    transform 0.14s var(--ease-out),
    visibility 0s;
}

.unsaved[data-shown="false"] {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  visibility: hidden;
}

.unsaved .icon {
  flex: none;
  color: var(--caution);
}

.unsaved__text {
  flex: 1;
  min-width: 0;
}

.unsaved__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: none;
}

.popover,
.dtp__panel {
  position: fixed;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--bg-canvas);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-high);
  max-height: calc(100vh - 16px);
  overflow-y: auto;
  animation: popover-in 0.12s var(--ease-out) both;
}

.dtp__panel {
  width: min(300px, calc(100vw - 16px));
}

@keyframes popover-in {
  from {
    opacity: 0;
    transform: translateY(-2px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .popover,
  .dtp__panel {
    animation: none;
  }
}

.dtp__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.dtp__month {
  font-weight: 600;
  color: var(--text-strong);
}

.dtp__weekdays,
.dtp__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.dtp__weekdays span {
  text-align: center;
  font-size: var(--step--2);
  color: var(--text-faint);
}

.dtp__day {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-normal);
  font: inherit;
  font-size: var(--step--1);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background 0.12s var(--ease-out), color 0.12s var(--ease-out);
}

.dtp__day:hover {
  background: var(--bg-raised);
  color: var(--text-strong);
}

.dtp__day[data-today="true"] {
  border-color: var(--line-strong);
}

.dtp__day[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-on-accent);
}

.dtp__day--blank {
  cursor: default;
}

.dtp__day--blank:hover {
  background: none;
}

.dtp__time {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px solid var(--line-soft);
}

.select--compact {
  width: auto;
  padding: 6px 28px 6px 10px;
  background-position:
    calc(100% - 14px) calc(50% + 1px),
    calc(100% - 9px) calc(50% + 1px);
  font-variant-numeric: tabular-nums;
}

.dtp__colon {
  color: var(--text-faint);
}

.dtp__meridiems {
  display: flex;
  margin-left: auto;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.dtp__meridiem {
  padding: 6px 10px;
  background: none;
  border: 0;
  color: var(--text-muted);
  font: inherit;
  font-size: var(--step--1);
  cursor: pointer;
}

.dtp__meridiem[aria-pressed="true"] {
  background: var(--accent);
  color: var(--text-on-accent);
}

.dtp__foot {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px solid var(--line-soft);
}

.dtp__hint {
  font-size: var(--step--2);
  color: var(--text-faint);
}

.dtp__foot .dtp__hint {
  margin-right: auto;
}

.rolesel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.rolesel__empty {
  font-size: var(--step--1);
  color: var(--text-faint);
}

.rolesel__chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  max-width: 100%;
  padding: 4px 4px 4px 10px;
  background: var(--bg-input);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-pill);
  font-size: var(--step--1);
  color: var(--text-strong);
}

.rolesel__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
}

.rolesel__chip-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rolesel__remove {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  transition: background 0.12s var(--ease-out), color 0.12s var(--ease-out);
}

.rolesel__remove .icon {
  width: 12px;
  height: 12px;
}

.rolesel__remove:hover {
  background: var(--bg-raised);
  color: var(--text-strong);
}

.rolesel__add,
.rolesel__more {
  display: grid;
  place-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: var(--step--1);
  cursor: pointer;
  transition: background 0.12s var(--ease-out), color 0.12s var(--ease-out), border-color 0.12s var(--ease-out);
}

.rolesel__add {
  width: 28px;
  padding: 0;
}

.rolesel__add .icon {
  width: 14px;
  height: 14px;
}

.rolesel__add:hover,
.rolesel__more:hover {
  background: var(--bg-raised);
  border-color: var(--line-strong);
  color: var(--text-strong);
}

.rolesel__panel {
  width: min(300px, calc(100vw - 16px));
  max-height: min(340px, calc(100vh - 32px));
  padding: var(--space-3);
  gap: var(--space-2);
}

.rolesel__list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow-y: auto;
  min-height: 0;
}

.rolesel__option {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 8px var(--space-2);
  background: none;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--text-normal);
  font: inherit;
  font-size: var(--step--1);
  text-align: left;
  cursor: pointer;
}

.rolesel__option:hover {
  background: var(--bg-raised);
  color: var(--text-strong);
}

.rolesel__option-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rolesel__none {
  padding: var(--space-4) var(--space-2);
  font-size: var(--step--1);
  color: var(--text-faint);
  text-align: center;
}

.imgfield {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.imgfield__uploaded {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2);
  background: var(--bg-input);
  border-radius: var(--radius-sm);
}

.imgfield__thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex: none;
}

.imgfield__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--step--2);
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.imgfield__actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.imgfield__actions .field__hint {
  flex: 1;
  min-width: 140px;
  font-size: var(--step--2);
}

.chsel__trigger {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-strong);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.16s var(--ease-out);
}

.chsel__trigger:hover:not(:disabled) {
  border-color: var(--line-soft);
}

.chsel__trigger[aria-expanded="true"] {
  border-color: var(--focus);
}

.chsel__trigger:disabled {
  color: var(--text-faint);
  cursor: not-allowed;
}

.chsel__trigger .icon {
  flex: none;
  color: var(--text-faint);
}

.chsel__trigger[data-empty="true"] .chsel__label {
  color: var(--text-faint);
}

.chsel__label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chsel__caret {
  width: 14px;
  height: 14px;
  transform: rotate(90deg);
}

.chsel__panel {
  width: min(320px, calc(100vw - 16px));
  max-height: min(380px, calc(100vh - 32px));
  padding: var(--space-3);
  gap: var(--space-2);
}

.chsel__list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow-y: auto;
  min-height: 0;
}

.chsel__category {
  padding: var(--space-3) var(--space-2) var(--space-1);
  font-size: var(--step--2);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.chsel__option {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 7px var(--space-2);
  background: none;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font: inherit;
  font-size: var(--step--1);
  text-align: left;
  cursor: pointer;
}

.chsel__option:hover {
  background: var(--bg-raised);
  color: var(--text-strong);
}

.chsel__option[aria-selected="true"] {
  background: var(--accent-quiet);
  color: var(--text-strong);
}

.chsel__option .icon {
  flex: none;
  width: 16px;
  height: 16px;
  color: var(--text-faint);
}

.chsel__option-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chsel__tick {
  color: var(--accent) !important;
}

.chsel__empty {
  padding: var(--space-4) var(--space-2);
  font-size: var(--step--1);
  color: var(--text-faint);
  text-align: center;
}

.cp__trigger {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-strong);
  font: inherit;
  font-size: var(--step--1);
  cursor: pointer;
  transition: border-color 0.16s var(--ease-out);
}

.cp__trigger:hover:not(:disabled) {
  border-color: var(--line-soft);
}

.cp__trigger[aria-expanded="true"] {
  border-color: var(--focus);
}

.cp__trigger:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.cp__swatch {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  box-shadow: inset 0 0 0 1px var(--ring-contrast);
}

.cp__readout {
  font-family: var(--font-mono);
  font-size: var(--step--2);
  letter-spacing: 0.04em;
}

.cp__panel {
  width: 248px;
}

.cp__area {
  position: relative;
  height: 136px;
  border-radius: var(--radius-sm);
  cursor: crosshair;
  touch-action: none;
}

.cp__hue {
  position: relative;
  height: 12px;
  border-radius: var(--radius-pill);
  cursor: ew-resize;
  touch-action: none;
  background: linear-gradient(
    to right,
    #f00 0%,
    #ff0 17%,
    #0f0 33%,
    #0ff 50%,
    #00f 67%,
    #f0f 83%,
    #f00 100%
  );
}

.cp__thumb {
  position: absolute;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px #fff, 0 1px 3px rgb(0 0 0 / 0.5);
  pointer-events: none;
}

.cp__thumb--hue {
  top: 50%;
}

.cp__row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.cp__hex {
  font-family: var(--font-mono);
  text-transform: uppercase;
}

.cp__presets {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: var(--space-2);
}

.cp__preset {
  aspect-ratio: 1;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--wash-4);
  transition: transform 0.12s var(--ease-out);
}

.cp__preset:hover {
  transform: scale(1.12);
}

.cp__preset[aria-pressed="true"] {
  box-shadow: 0 0 0 2px var(--bg-canvas), 0 0 0 4px var(--text-strong);
}

.token-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: calc(var(--space-2) * -1);
}

.token {
  font: inherit;
  font-size: var(--step--2);
  font-family: var(--font-mono);
  color: var(--text-muted);
  background: var(--bg-input);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 2px var(--space-2);
  cursor: pointer;
  transition: color .12s ease, background .12s ease, border-color .12s ease;
}

.token:hover:not(:disabled) {
  color: var(--text-strong);
  background: var(--bg-raised);
  border-color: var(--line-strong);
}

.token:disabled {
  cursor: default;
  opacity: .5;
}

.token[aria-pressed="true"] {
  color: var(--text-strong);
  background: var(--accent-quiet);
  border-color: var(--accent);
}

.md-heading {
  font-size: var(--step-0);
  font-weight: 700;
  color: var(--text-strong);
  margin: var(--space-3) 0 var(--space-1);
  display: block;
}

h1.md-heading {
  font-size: var(--step-2);
}

h2.md-heading {
  font-size: var(--step-1);
}

.md-list {
  display: block;
  padding-left: var(--space-5);
  margin: var(--space-1) 0;
}

.md-list li {
  display: list-item;
}

.md-list[data-ordered="false"] li {
  list-style: disc;
}

.md-list[data-ordered="true"] li {
  list-style: decimal;
}

.md-quote {
  display: block;
  margin: var(--space-1) 0;
  padding-left: var(--space-3);
  border-left: 4px solid var(--line-strong);
  border-radius: 2px;
}

.md-code {
  background: var(--bg-rail);
  border-radius: 3px;
  padding: 1px 3px;
  font-family: var(--font-mono);
  font-size: 0.85em;
}

.md-block {
  display: block;
  margin: var(--space-2) 0;
  padding: var(--space-3);
  background: var(--bg-rail);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  white-space: pre;
}

.md-block code {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--text-muted);
}

.md-link {
  color: var(--link);
  text-decoration: none;
}

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

.md-mention {
  background: var(--accent-quiet);
  color: var(--accent-text);
  border-radius: 3px;
  padding: 0 2px;
  font-weight: 500;
}

.md-emoji {
  color: var(--text-muted);
}

.md-spoiler {
  background: var(--bg-rail);
  border-radius: 3px;
  color: transparent;
}

.md-spoiler:hover {
  color: inherit;
}

.embed__footer {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--step--2);
  color: var(--text-faint);
}

@media (max-width: 860px) {
  .cp__panel {
    width: calc(100vw - 16px);
  }

  .cp__area {
    height: 200px;
  }

  .cp__hue {
    height: 20px;
  }

  .cp__thumb {
    width: 22px;
    height: 22px;
    margin: -11px 0 0 -11px;
  }

  .cp__presets {
    grid-template-columns: repeat(6, 1fr);
    gap: var(--space-3);
  }

  .cp__hex {
    min-height: 44px;
  }

  .popover .button--small {
    min-height: 44px;
  }
}

.popover-scrim {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 55;
  background: var(--bg-overlay);
  animation: popover-in 0.12s var(--ease-out) both;
}

@media (max-width: 860px) {
  .popover-scrim {
    display: block;
  }
}

@media (max-width: 860px) {
  .rolesel__panel,
  .chsel__panel {
    width: calc(100vw - 16px);
    max-height: min(72vh, 560px);
    padding: var(--space-3);
    gap: var(--space-3);
  }

  .rolesel__list,
  .chsel__list {
    gap: var(--space-1);
  }

  .rolesel__option,
  .chsel__option {
    min-height: 48px;
    padding: 0 var(--space-3);
    font-size: var(--step-0);
  }

  .chsel__category {
    padding: var(--space-3) var(--space-3) var(--space-1);
  }

  .rolesel__chip {
    padding: 6px 6px 6px var(--space-3);
  }

  .rolesel__remove {
    width: 32px;
    height: 32px;
  }

  .rolesel__remove .icon {
    width: 16px;
    height: 16px;
  }

  .rolesel__add,
  .rolesel__more {
    min-height: 40px;
    padding: 0 var(--space-4);
  }

  .rolesel__add {
    width: 40px;
    padding: 0;
  }

  .rolesel__add .icon {
    width: 18px;
    height: 18px;
  }

  .chsel__trigger {
    min-height: 48px;
  }
}

.emojisel__trigger {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 40px;
  padding: 0 var(--space-3);
  background: var(--bg-input);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-strong);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.16s var(--ease-out);
}

.emojisel__trigger:hover:not(:disabled) {
  border-color: var(--line-soft);
}

.emojisel__trigger[aria-expanded="true"] {
  border-color: var(--focus);
}

.emojisel__trigger:disabled {
  color: var(--text-faint);
  cursor: not-allowed;
}

.emojisel__preview {
  display: inline-flex;
  align-items: center;
  font-size: var(--step-2);
  line-height: 1;
}

.emojisel__label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--step--1);
  color: var(--text-muted);
}

.emojisel__caret {
  flex: none;
  margin-left: auto;
  color: var(--text-faint);
  transform: rotate(90deg);
  transition: transform 0.16s var(--ease-out);
}

.emojisel__trigger[aria-expanded="true"] .emojisel__caret {
  transform: rotate(-90deg);
}

.emojisel__panel {
  width: min(360px, calc(100vw - 16px));
  max-height: min(420px, calc(100vh - 32px));
  padding: var(--space-3);
  gap: var(--space-2);
}

.emojisel__tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: var(--space-1);
  box-shadow: inset 0 -1px 0 var(--line-soft);
}

.emojisel__tab {
  flex: none;
  display: grid;
  place-items: center;
  overflow: hidden;
  width: 34px;
  height: 32px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: var(--step-0);
  line-height: 1;
  cursor: pointer;
  filter: grayscale(1);
  opacity: 0.6;
  transition: opacity 0.12s var(--ease-out), background 0.12s var(--ease-out);
}

.emojisel__tab:hover,
.emojisel__tab[aria-selected="true"] {
  filter: none;
  opacity: 1;
  background: var(--bg-raised);
}

.emojisel__heading {
  font-size: var(--step--2);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.emojisel__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
  grid-auto-rows: 38px;
  gap: 2px;
  overflow-y: auto;
  min-height: 0;
}

.emojisel__cell {
  display: grid;
  place-items: center;
  overflow: hidden;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: var(--step-1);
  line-height: 1;
  cursor: pointer;
  transition: background 0.12s var(--ease-out);
}

.emojisel__cell:hover {
  background: var(--bg-raised);
}

.emojisel__cell[aria-pressed="true"] {
  background: var(--accent-quiet);
  box-shadow: inset 0 0 0 1px var(--accent-line);
}

.emojisel__glyph {
  line-height: 1;
}

.emojisel__glyph--name {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: var(--step--2);
  color: var(--text-muted);
}

img.emojisel__glyph {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.emojisel__preview img.emojisel__glyph {
  width: 28px;
  height: 28px;
}

.emojisel__tab img.emojisel__glyph {
  width: 20px;
  height: 20px;
}

@media (max-width: 860px) {
  .emojisel__panel {
    width: calc(100vw - 16px);
    max-height: min(72vh, 560px);
  }

  .emojisel__trigger {
    min-height: 48px;
  }

  .emojisel__search {
    min-height: 44px;
  }

  .emojisel__tab {
    width: 44px;
    height: 44px;
    font-size: var(--step-1);
  }

  .emojisel__grid {
    grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
    grid-auto-rows: 46px;
    gap: var(--space-1);
  }

  .emojisel__cell {
    font-size: var(--step-2);
  }

  img.emojisel__glyph {
    width: 30px;
    height: 30px;
  }
}

.popover[data-placement="sheet"],
.dtp__panel[data-placement="sheet"] {
  inset: auto 0 0 0;
  width: auto;
  min-width: 0;
  max-width: none;
  max-height: min(86vh, 720px);
  padding: 0 var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom));
  border: 0;
  border-top: 1px solid var(--line-soft);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  animation: sheet-in 0.22s var(--ease-out) both;
}

@keyframes sheet-in {
  from {
    transform: translateY(12px);
    opacity: 0;
  }
}

.popover__head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: 0 calc(var(--space-4) * -1);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-canvas);
  box-shadow: inset 0 -1px 0 var(--line-soft);
}

.popover__head::before {
  content: "";
  position: absolute;
  top: 6px;
  left: 50%;
  width: 36px;
  height: 4px;
  margin-left: -18px;
  border-radius: var(--radius-pill);
  background: var(--line-strong);
}

.popover__title {
  flex: 1;
  min-width: 0;
  padding-top: var(--space-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--step-0);
  font-weight: 700;
  color: var(--text-strong);
}

.popover__close {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-top: var(--space-2);
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--text-muted);
  font-size: var(--step-0);
  line-height: 1;
  cursor: pointer;
}

.popover__close:hover {
  color: var(--text-strong);
}

[data-placement="sheet"] .chsel__list,
[data-placement="sheet"] .rolesel__list,
[data-placement="sheet"] .emojisel__grid {
  max-height: none;
}

.emojisel__search,
.emojisel__tabs,
.emojisel__heading,
.chsel__search,
.rolesel__search {
  flex: none;
}

.emojisel__grid,
.chsel__list,
.rolesel__list {
  flex: 1 1 auto;
  min-height: 0;
}

.memsel {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.memsel__list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.memsel__row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2);
  background: var(--bg-input);
  border-radius: var(--radius-sm);
}

.memsel__avatar {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-sunken);
}

.memsel__avatar--initial {
  display: grid;
  place-items: center;
  font-size: var(--step--1);
  font-weight: 700;
  color: var(--text-muted);
}

.memsel__who {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.memsel__name {
  font-size: var(--step--1);
  font-weight: 600;
  color: var(--text-strong);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.memsel__id {
  font-family: var(--font-mono);
  font-size: var(--step--2);
  color: var(--text-faint);
}

.memsel__add {
  display: flex;
  gap: var(--space-2);
}

.memsel__search {
  font-family: var(--font-mono);
  font-size: var(--step--1);
}

@media (max-width: 860px) {
  .memsel__row {
    padding: var(--space-3);
  }

  .memsel__search {
    min-height: 44px;
  }
}

.member {
  cursor: context-menu;
}

.member:hover {
  text-decoration: underline dotted var(--line-strong);
  text-underline-offset: 3px;
}

.member--link {
  cursor: pointer;
  color: inherit;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentColor 32%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.member--link:hover {
  color: var(--text-strong);
  text-decoration: underline;
  text-decoration-color: currentColor;
  text-underline-offset: 2px;
}

.member:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.ctxmenu-scrim {
  position: fixed;
  inset: 0;
  z-index: 310;
}

.ctxmenu {
  position: fixed;
  z-index: 320;
  min-width: 210px;
  max-width: min(280px, calc(100vw - 16px));
  max-height: calc(100vh - 16px);
  overflow-y: auto;
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--bg-sidebar);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-high);
  animation: popover-in 0.1s var(--ease-out) both;
}

.ctxmenu__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-normal);
  font: inherit;
  font-size: var(--step--1);
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}

.ctxmenu__item .icon {
  width: 16px;
  height: 16px;
  flex: none;
  color: var(--text-faint);
}

.ctxmenu__item:hover,
.ctxmenu__item:focus-visible {
  background: var(--accent);
  color: var(--text-on-accent);
  outline: none;
}

.ctxmenu__item:hover .icon,
.ctxmenu__item:focus-visible .icon {
  color: var(--text-on-accent);
}

.ctxmenu__item--danger {
  color: var(--danger);
}

.ctxmenu__item--danger:hover,
.ctxmenu__item--danger:focus-visible {
  background: var(--danger);
  color: var(--text-on-accent);
}

.ctxmenu__label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ctxmenu__badge {
  flex: none;
  padding: 1px 4px;
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: var(--step--2);
  font-weight: 700;
}

.ctxmenu__item:hover .ctxmenu__badge,
.ctxmenu__item:focus-visible .ctxmenu__badge {
  background: var(--wash-5);
  color: var(--text-on-accent);
}

.ctxmenu__rule {
  height: 1px;
  margin: var(--space-2) var(--space-1);
  background: var(--line-soft);
}

@media (max-width: 860px) {
  .ctxmenu[data-placement="sheet"] {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: none;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: var(--space-3) var(--space-3) var(--space-5);
    gap: var(--space-1);
  }

  .ctxmenu[data-placement="sheet"] .ctxmenu__item {
    min-height: 44px;
    font-size: var(--step-0);
  }

  .ctxmenu-scrim {
    background: var(--bg-overlay);
  }
}

.link {
  color: inherit;
  border-radius: var(--radius-sm);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentColor 32%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.link:hover {
  color: var(--text-strong);
  text-decoration-color: currentColor;
}

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

.link:has(img) {
  text-decoration: none;
}

.link img {
  display: block;
}

.link:hover img {
  outline: 2px solid var(--accent-line);
  outline-offset: 1px;
}

.rail__row {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding-right: var(--space-2);
  border-radius: var(--radius-sm);
  transition: background-color 0.12s var(--ease-out);
}

.rail__row:hover {
  background: var(--wash-1);
}

.rail__row[data-current="true"] {
  background: color-mix(in srgb, var(--event, #ffffff) 16%, var(--wash-2));
}

.rail__row .rail__item {
  flex: 1;
  min-width: 0;
}

.rail__row .rail__item:hover,
.rail__row .rail__item[aria-current="true"] {
  background: transparent;
}

.rail__cog {
  flex: none;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-faint);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s var(--ease-out), color 0.12s var(--ease-out);
}

.rail__cog .icon {
  width: 15px;
  height: 15px;
}

.rail__row:hover .rail__cog,
.rail__cog:focus-visible {
  opacity: 1;
}

.rail__cog:hover {
  color: var(--text-strong);
  background: var(--wash-3);
}

.tri {
  display: inline-flex;
  flex: none;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-input);
}

.tri__button {
  width: 42px;
  height: 32px;
  border: 0;
  background: none;
  color: var(--text-faint);
  font-size: var(--step--1);
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.tri__button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.tri__button:hover:not(:disabled) {
  background: var(--bg-raised);
}

.tri__button--deny[aria-pressed="true"] {
  background: var(--danger-quiet);
  color: var(--danger);
}

.tri__button--inherit[aria-pressed="true"] {
  background: var(--bg-raised);
  color: var(--text-normal);
}

.tri__button--allow[aria-pressed="true"] {
  background: var(--positive-quiet);
  color: var(--positive);
}

.tri__button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

.dialog.perm-dialog {
  width: min(1120px, 100%);
  max-height: min(860px, 100%);
}

.perm-dialog .dialog__body {
  padding: var(--space-5) var(--space-6) var(--space-6);
}

.perm-dialog__body {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: var(--space-6);
  align-items: start;
}

.perm-dialog__targets {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-height: min(58vh, 620px);
  overflow-y: auto;
}

.perm-dialog__targets-head {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  align-items: flex-start;
  padding-bottom: var(--space-2);
}

.perm-dialog__target {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding-right: var(--space-3);
  border-radius: var(--radius-sm);
}

.perm-dialog__avatar {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-input);
}

.perm-dialog__avatar--initial {
  display: grid;
  place-items: center;
  font-size: var(--step--2);
  font-weight: 700;
  color: var(--text-muted);
}

.perm-dialog__target[data-current="true"] {
  background: var(--bg-raised);
}

.perm-dialog__pick {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-3);
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-normal);
  font: inherit;
  font-size: var(--step--1);
  text-align: left;
  cursor: pointer;
}

.perm-dialog__pick:hover {
  color: var(--text-strong);
}

.perm-dialog__pick .icon {
  width: 16px;
  height: 16px;
  flex: none;
  color: var(--text-faint);
}

.perm-dialog__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.perm-dialog__counts {
  font-family: var(--font-mono);
  font-size: var(--step--2);
  color: var(--text-faint);
}

.perm-dialog__remove {
  flex: none;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-faint);
  line-height: 0;
  cursor: pointer;
}

.perm-dialog__remove .icon {
  display: block;
  width: 15px;
  height: 15px;
}

.perm-dialog__remove:hover {
  color: var(--danger);
  background: var(--danger-quiet);
}

.perm-dialog__rows {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  max-height: min(58vh, 620px);
  padding-right: var(--space-3);
}

.perm-dialog__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-5);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--line-soft);
}

.perm-dialog__row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.perm-dialog__what {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.perm-dialog__label {
  font-size: var(--step-0);
  font-weight: 600;
  color: var(--text-strong);
}

.perm-dialog__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--line-soft);
}

.picker {
  width: min(320px, calc(100vw - 24px));
  gap: var(--space-2);
}

.picker__list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 240px;
  overflow-y: auto;
}

.picker__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-normal);
  font: inherit;
  font-size: var(--step--1);
  text-align: left;
  cursor: pointer;
}

.picker__row:hover {
  background: var(--bg-raised);
  color: var(--text-strong);
}

.picker__kind {
  flex: none;
  font-size: var(--step--2);
  color: var(--text-faint);
}

@media (max-width: 860px) {
  .perm-dialog__body {
    grid-template-columns: minmax(0, 1fr);
  }

  .rail__cog {
    opacity: 1;
  }
}

.key-window {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.key {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-3);
  background: var(--bg-input);
  border-radius: var(--radius-sm);
}

.key__avatar {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-sunken);
}

.key__avatar--initial {
  display: grid;
  place-items: center;
  font-size: var(--step--1);
  font-weight: 700;
  color: var(--text-muted);
}

.key__head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.key__name {
  font-weight: 600;
  color: var(--text-strong);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.key__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-1);
}

.key__url {
  font-family: var(--font-mono);
  font-size: var(--step--2);
  overflow-wrap: anywhere;
  color: var(--text-strong);
}

.key + .key {
  margin-top: var(--space-2);
}

.resultcard__frame {
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-sunken);
  box-shadow: 0 12px 30px var(--shadow-key);
}

.resultcard__canvas {
  display: block;
  width: 100%;
  height: auto;
}

.resultcard__waiting {
  width: 100%;
  aspect-ratio: 16 / 9;
}

.statscard__waiting {
  width: 100%;
  aspect-ratio: 16 / 9;
}

.perm-check {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
}

.perm-check[data-state="missing"],
.perm-check[data-state="gone"] {
  background: var(--danger-quiet);
}

.perm-check[data-state="ok"] > .icon {
  color: var(--positive);
}

.perm-check[data-state="missing"] > .icon,
.perm-check[data-state="gone"] > .icon {
  color: var(--danger);
}

.perm-check > .icon {
  flex: none;
  margin-top: 2px;
}

.perm-check__body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.perm-check__head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.perm-check__name {
  font-weight: 600;
  color: var(--text-strong);
}

.perm-check__missing {
  font-size: var(--step--1);
  font-weight: 600;
  color: var(--danger-text);
}

.perm-check__why {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: var(--step--1);
  color: var(--text-faint);
}

.perm-check__why li::before {
  content: "\2013";
  margin-right: var(--space-2);
  opacity: 0.6;
}

.perm-check__steps {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: var(--space-1);
  padding-left: var(--space-4);
  list-style: decimal;
  font-size: var(--step--1);
  color: var(--text-muted);
}

.perm-check__body > .button {
  align-self: flex-start;
  margin-top: var(--space-2);
}

.perm-check + .perm-check {
  margin-top: var(--space-2);
}

.memsel__head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.discord-preview__photo {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.discord-preview__note {
  margin-top: calc(var(--space-2) * -1);
}
