.v3-settings-panel {
  position: fixed;
  top: calc(var(--v3-shell-pad-y) + 52px);
  right: max(var(--v3-shell-pad-x), calc((100vw - var(--v3-shell-max)) / 2 + var(--v3-shell-pad-x)));
  z-index: 18;
  width: min(420px, calc(100vw - 32px));
  transform-origin: top right;
}

.v3-settings-panel[hidden] {
  display: none;
}

.v3-settings-panel__card {
  position: relative;
  display: grid;
  gap: 0.68rem;
  max-height: min(calc(100vh - (var(--v3-shell-pad-y) + 56px)), 820px);
  padding: 0.85rem var(--v3-space-4) var(--v3-space-4);
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-color: var(--v3-theme-control-border) transparent;
  scrollbar-width: thin;
  border: 1px solid var(--v3-theme-border);
  border-radius: var(--v3-radius-card);
  background: var(--v3-theme-surface-elevated);
  box-shadow: 0 22px 54px var(--v3-theme-panel-shadow-color);
}

.v3-settings-panel__card::-webkit-scrollbar {
  width: 8px;
}

.v3-settings-panel__card::-webkit-scrollbar-track {
  background: transparent;
}

.v3-settings-panel__card::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: var(--v3-radius-pill);
  background-color: var(--v3-theme-control-border);
  background-clip: content-box;
}

.v3-settings-panel__close {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  justify-self: end;
  min-height: 34px;
  padding: 0 var(--v3-space-2);
  border: 1px solid var(--v3-theme-control-border);
  border-radius: var(--v3-radius-pill);
  background: var(--v3-theme-control-bg);
  color: var(--v3-theme-control-text-strong);
  font: inherit;
  font-weight: 850;
  cursor: pointer;
}

.v3-settings-panel__header {
  display: grid;
  gap: 0.18rem;
  min-height: 34px;
  padding-right: 5.5rem;
}

.v3-settings-panel__header h2 {
  margin: 0;
}

.v3-settings-section,
.v3-settings-admin-signpost {
  display: grid;
  gap: var(--v3-space-3);
  padding: var(--v3-space-3);
  border: 1px solid var(--v3-theme-divider);
  border-radius: var(--v3-radius-card);
  background: var(--v3-theme-surface-muted);
  color: var(--v3-theme-text);
}

.v3-settings-section__head {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: var(--v3-space-2);
  align-items: start;
  min-width: 0;
}

.v3-settings-section__head h3,
.v3-settings-section__head p {
  margin: 0;
}

.v3-settings-section__head h3 {
  color: var(--v3-theme-text-strong);
  font-size: 0.98rem;
  line-height: 1.2;
}

.v3-settings-section__head p {
  color: var(--v3-theme-text-muted);
  font-size: 0.88rem;
  line-height: 1.35;
}

.v3-settings-section__icon,
.v3-settings-status-row__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--v3-theme-control-border);
  border-radius: var(--v3-radius-control);
  background: var(--v3-theme-control-bg);
  color: var(--v3-theme-control-text-strong);
}

.v3-settings-section__icon svg,
.v3-settings-status-row__icon svg {
  width: 17px;
  height: 17px;
}

.v3-settings-panel__facts {
  display: grid;
  gap: 0.45rem;
  margin: 0;
}

.v3-settings-panel__facts div {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: var(--v3-space-2);
  align-items: center;
  min-width: 0;
  padding: 0.58rem 0.68rem;
  border: 1px solid var(--v3-theme-control-border);
  border-radius: var(--v3-radius-control);
  background: var(--v3-theme-surface-elevated);
}

.v3-settings-panel__facts div::after {
  content: none;
}

.v3-settings-panel__facts dt {
  grid-column: 1;
  color: var(--v3-theme-text-muted);
  font-size: 0.74rem;
  font-weight: 850;
  text-transform: uppercase;
}

.v3-settings-panel__facts dd {
  grid-column: 2;
  justify-self: end;
  min-width: 0;
  max-width: 100%;
  margin: 0;
  color: var(--v3-theme-text-strong);
  font-weight: 800;
  text-align: right;
  overflow-wrap: anywhere;
}

.v3-settings-theme {
  margin: 0;
}

.v3-settings-theme__label {
  color: var(--v3-theme-text-strong);
  font-size: 0.98rem;
  font-weight: 850;
  text-transform: none;
}

.v3-theme-control {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  min-width: 0;
  padding: 4px;
  border: 1px solid var(--v3-theme-control-border);
  border-radius: var(--v3-radius-pill);
  background: var(--v3-theme-surface-muted);
}

.v3-theme-control__option {
  min-width: 0;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.34rem;
  padding: 0 var(--v3-space-2);
  border: 1px solid transparent;
  border-radius: var(--v3-radius-pill);
  background: transparent;
  color: var(--v3-theme-text-muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 850;
  cursor: pointer;
}

.v3-theme-control__option svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.v3-theme-control__option span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.v3-theme-control__option:focus-visible,
.v3-theme-control__option.is-active {
  border-color: var(--v3-theme-focus-active-border);
  background: var(--v3-theme-control-bg);
  color: var(--v3-theme-control-text-strong);
  box-shadow: 0 0 0 3px var(--v3-theme-focus-active-shadow);
  outline: none;
}

.v3-settings-admin-signpost[hidden] {
  display: none;
}

.v3-settings-admin-signpost__rows {
  display: grid;
  gap: var(--v3-space-2);
}

.v3-settings-status-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) max-content;
  gap: var(--v3-space-2);
  align-items: center;
  min-width: 0;
  padding: var(--v3-space-2);
  border: 1px solid var(--v3-theme-control-border);
  border-radius: var(--v3-radius-control);
  background: var(--v3-theme-surface-elevated);
}

.v3-settings-status-row div {
  display: grid;
  gap: 0.1rem;
  min-width: 0;
}

.v3-settings-status-row strong {
  color: var(--v3-theme-text-strong);
  font-size: 0.88rem;
  line-height: 1.25;
}

.v3-settings-status-row span:not([class]) {
  color: var(--v3-theme-text-muted);
  font-size: 0.8rem;
  line-height: 1.3;
}

.v3-settings-status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 0.45rem;
  border: 1px solid var(--v3-theme-divider);
  border-radius: var(--v3-radius-pill);
  background: transparent;
  color: var(--v3-theme-text-muted);
  font-size: 0.7rem;
  font-weight: 800;
  white-space: nowrap;
  cursor: default;
  pointer-events: none;
}

.v3-settings-panel__note {
  margin: 0;
  color: var(--v3-theme-text-muted);
  line-height: 1.4;
}

@media (max-width: 640px) {
  .v3-settings-panel {
    top: calc(var(--v3-shell-pad-y) + 58px);
    right: max(10px, env(safe-area-inset-right));
    bottom: max(14px, env(safe-area-inset-bottom));
    left: max(10px, env(safe-area-inset-left));
    width: auto;
  }

  .v3-settings-panel__card {
    gap: 0.55rem;
    max-height: 100%;
    padding: 0.72rem var(--v3-space-3) calc(var(--v3-space-5) + env(safe-area-inset-bottom));
  }

  .v3-settings-panel__close {
    top: 0.58rem;
    right: 0.58rem;
  }

  .v3-settings-panel__header {
    padding-right: 5rem;
  }

  .v3-settings-status-row {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .v3-settings-status-chip {
    grid-column: 2;
    justify-self: start;
  }
}

@media (max-width: 420px) {
  .v3-settings-section,
  .v3-settings-admin-signpost {
    padding: var(--v3-space-2);
  }

  .v3-settings-panel__facts div {
    grid-template-columns: 1fr;
    gap: 0.18rem;
  }

  .v3-settings-panel__facts dd {
    justify-self: start;
    text-align: left;
  }

  .v3-theme-control__option {
    min-height: 42px;
    padding: 0 var(--v3-space-1);
  }
}
